3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function _flatten_array($arr) { while ($arr) { list($key, $value) = each($arr); is_array($value) ? $arr = $value : $out[$key] = $value; unset($arr[$key]); } return (array)$out; } $aNonFlat = array( 1, 2, array( 3, 4, 5, array( 6, 7 ), 8, 9, ), 10, 11 ); var_export(_flatten_array($aNonFlat));
based on X0aeS
Output for 7.2.0 - 7.3.1
Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /in/7cO9N on line 4 array ( 0 => 6, 1 => 7, )
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.1.25
array ( 0 => 6, 1 => 7, )