3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ 1 => "tenants", 2 => "modules", ]; $array2 = [ "prefix" => "tenants", "slug" => "tenants", "child" => [ [ "prefix" => "modules/{id}", "slug" => "modules" ], [ "prefix" => "fetch/{id}", "slug" => "fetch" ], ], ]; function getFromChild($item, $asd) { if (!is_array($item)) return []; $res = []; if ($item["slug"] == $asd) $res[] = $item['prefix']; if (isset($item['child'])) foreach($item['child'] as $child) $res = array_merge($res, getFromChild($child, $asd)); return $res; } $res = []; foreach ($array1 as $asd) { $res = array_merge($res, getFromChild($array2, $asd)); } print_r($res);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => tenants [1] => modules/{id} )

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:
165.05 ms | 405 KiB | 5 Q