/ Published in: PHP

Can probably be done easier/better, but it accomplishes what I needed it to do. Figured I'd share.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function recursion($multi_dimensional_array) { $m = $multi_dimensional_array; foreach($m as $key=>$value) { $keys[] = $key; } $i = 0; { echo '<li><a href="#">'.$keys[$i].'</a>'; { echo '<ul>'; recursion($multi_dimensional_array[$keys[$i]]); echo '</ul>'; } echo '</li>'; $i++; } } ?> Usage Example: <ul> <? recursion($array); ?> </ul>
Comments
