3v4l.org

run code in 300+ PHP versions simultaneously
<?php header('content-type:text/plain'); function HTMLStringify($arr, $seen = array()) { if (is_array($arr)) { $seen[] = &$arr; $html = '<ul>'; foreach ($arr as $key => &$value) { $html .= '<li>' . $key; if (is_array($value)){ if(in_array($value, $seen, true)) { $html .= '*RECURSION*'; } else { $html .= HTMLStringify($value, $seen); } } elseif(is_numeric($value) || is_string($value) || is_null($value)) { $html .= ' = ' . $value; } else { $html .= ' [couldn\'t parse ' . gettype($value) . ']'; } $html .= '</li>'; } $html .= '</ul>'; return $html; } else { return null; } } $arr = array(1 => 'one', 2 => 'two'); $arr[3] = &$arr; echo HTMLStringify($arr);

preferences:
60.75 ms | 402 KiB | 5 Q