Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Created October 17, 2017 21:29
Show Gist options
  • Save adamculpepper/93838e1648416363a637ca2296f4daa5 to your computer and use it in GitHub Desktop.
Save adamculpepper/93838e1648416363a637ca2296f4daa5 to your computer and use it in GitHub Desktop.
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