3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function flatten_array($simple){ static $outputs=array(); foreach ( $simple as $value) { if(is_array($value)){ flatten_array($value); } else { $outputs[]=$value; } } return $outputs; } $eg=['s'=>['p','n'=>['t']]]; $out=flatten_array($eg); print_r($out); echo "\n---\n"; $out=flatten_array($eg); print_r($out);
based on Unoi3
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.2.7
Array ( [0] => p [1] => t ) --- Array ( [0] => p [1] => t [2] => p [3] => t )