/ Published in: PHP
Traverses a multidimensional array and returns an array with the results. It also echoes the result as a string just for demonstration.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function array_traverse($arr) { // Traverse array, if a value is an array do recursive call to traverse that array foreach($arr as $value) { { array_traverse($value); } else { $recursive_array[] = $value; echo $value."<br />\n"; } } return $recursive_array; }