Created
October 17, 2017 21:29
-
-
Save adamculpepper/93838e1648416363a637ca2296f4daa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print("<pre>" . print_r($array, true) . "</pre>"); | |
//https://stackoverflow.com/questions/4414623/loop-through-an-array-php | |
//Using foreach loop without key | |
foreach($array as $item) { | |
echo $item['filename']; | |
echo $item['filepath']; | |
// to know what's in $item | |
echo '<pre>'; var_dump($item); | |
} | |
//Using foreach loop with key | |
foreach($array as $i => $item) { | |
echo $array[$i]['filename']; | |
echo $array[$i]['filepath']; | |
// $array[$i] is same as $item | |
} | |
//Using for loop | |
for ($i = 0; $i < count($array); $i++) { | |
echo $array[$i]['filename']; | |
echo $array[$i]['filepath']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment