Re: What is meant by this code?
| From: | Lester Caine | Date: | Sat, 31 Jan 2015 08:28:06 +0000 |
| Subject: | Re: What is meant by this code? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324348@lists.php.net to get a copy of this message | ||
On 31/01/15 02:06, Ken Robinson wrote:
>> Hello,
>>
>> I'm new to PHP. I came across the following code:
>>
>> ....
>> ....
>> $exif = exif_read_data($image);
>> foreach ($exif as $key => $section) {
>> foreach ($section as $name => $val) {
>> .....
>> .....
>>
>> What are we doing here in the "foreach"? What is "as"?
>
> RTFM
>
> http://php.net/manual/en/control-structures.foreach.php
I've read the manual ... now I'm more confused :)
Seriously ... If one is starting to use PHP reading the manual is the
LAST place to start, but there is not a good alternative to direct
people to. Most tutorials are simply last in old style practices!
Abdul ...
A useful little trick is print_r($exif);
This will show just what has been returned by exif_read ... which is an
multi level array of data. foreach simply scans the array converting
each element of the array - in this case creating a copy of an element
in $section, but $section is an array itself so the second foreach pulls
out the values.
Now hopefully reading the manual will make a little more sense :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk