Search code examples
phparraysvariablesiptc

Strip a IPTC.php result into two variables


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.


Solution

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