0

I have the following code:

<?php
    require_once('IPTC.php');
    $iptc = new Image_IPTC('001.jpg');
    print_r($iptc);
?>

And it returns:

Image_IPTC Object ( [_sFilename] => 001.jpg [_aIPTC] => Array ( [1#090] => Array ( [0] => %G ) [2#000] => Array ( [0] => ) [2#005] => Array ( [0] => TITULO NO WINDOWS, TITLE NO BRIDGE ) [2#080] => Array ( [0] => pictureauthor ) [2#085] => Array ( [0] => photographer ) [2#090] => Array ( [0] => mycity ) [2#095] => Array ( [0] => ST ) [2#101] => Array ( [0] => mycountry ) [2#105] => Array ( [0] => IWANTTHIS1 ) [2#116] => Array ( [0] => copyrightinfo ) [2#120] => Array ( [0] => IWANTTHIS2 ) ) [_bIPTCParse] => 1 )

This is a dummy question, but how do I put texts "IWANTTHIS1" and "IWANTTHIS2" into 2 different variables to use like this:

echo "title: $variable1 <br />";
echo "descr: $variable2";

Resulting in:

title: IWANTTHIS1
descr: IWANTTHIS2

I'm pretty shure it's extremelly easy for you guys, but I'm still learning all this. I think it's an array inside an array? Can't figure it out.

Thanks.

OleSchmitt
  • 165
  • 1
  • 8

2 Answers2

2
$variable1 = $iptc->_aIPTC['2#105'][0]; 
$variable2 = $iptc->_aIPTC['2#120'][0];
Rodaine
  • 1,018
  • 7
  • 13
1

Rodaine's answer was giving me "Fatal error: Cannot use object of type Image_IPTC as array". With some research, the final correct answer is:

$variable1 = $iptc->_aIPTC['2#105'][0];
$variable2 = $iptc->_aIPTC['2#120'][0];

I wouldn't be able to achieve it by myself at all, therefore I'm marking Rodaine's answer as correct.

Thank you very much.

OleSchmitt
  • 165
  • 1
  • 8