Created
March 8, 2016 10:57
-
-
Save alekpopovic/b8836481536c8fd0653a to your computer and use it in GitHub Desktop.
Recursive Array Iterator
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
<?php | |
###################################### | |
# | |
# Author: Aleksandar Popovic | |
# | |
# A recursive function to traverse a multi-dimensional array | |
# where the dimensions are not known | |
# | |
####################################### | |
function get_array_elems($arrResult, $where="array"){ | |
while(list($key,$value)=each($arrResult)){ | |
if (is_array($value)){ | |
get_array_elems($value, $where."[$key]"); | |
} | |
else { | |
for ($i=0; $i<count($value);$i++){ | |
echo $where."[$key]=".$value."<BR>\n"; | |
} | |
} | |
} | |
} | |
get_array_elems($arrResult); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment