/** * Creates recursively a nested HTML UL of array keys. * @param array $array Array * @return string Nested UL string */ function Get_Array_Keys_UL($array=array()) { $recursion=__FUNCTION__; if (empty($array)) return ''; $out='<ul>'."\n"; foreach ($array as $key => $elem) $out .= '<li>'.$key.$recursion($elem).'</li>'."\n"; $out .= '</ul>'."\n"; return $out; }
Use like this:
$ul=Get_Array_Keys_UL($_POST); echo $ul;
A good tip I've picked up is to use print* for debug statements and echo for other output.