3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0 => [ "id" => "1", "color" => "red", ], 1 => [ 0 => [ "id" => "2", "color" => "blue", ], 1 => [ 0 => [ "id" => "3", "color" => "green", ], ], 2 => [ "id" => "4", "color" => "blue", ], ], 2 => [ "id" => "5", "color" => "purple", ], ]; function flattenArray($arr = []) { $retArr = []; foreach ($arr as $val) { if (is_array($val)) { $retArr[] = array_filter($val, function ($v) { return !is_array($v); }); $retArr = array_merge(array_filter($retArr), flattenArray($val)); } } return $retArr; } $arr = flattenArray($arr); print_r($arr);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [id] => 1 [color] => red ) [1] => Array ( [id] => 2 [color] => blue ) [2] => Array ( [id] => 3 [color] => green ) [3] => Array ( [id] => 4 [color] => blue ) [4] => Array ( [id] => 5 [color] => purple ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.4 ms | 406 KiB | 5 Q