3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ["farm"=> [ "horse"=> [ "rabbit"=> [ "name"=> "alan", "age"=> "21", "size"=> "166", "gender"=> "f" ], ] ] ]; function createList($array, $keySearch, $path=null) { $result = []; foreach ($array as $key => $item) { $basePath = $path === null ? $key : $path. "/" . $key; if (stripos($key, $keySearch) !== false && is_array($item)){ $result[] = ['key' => $key, 'basePath' => $basePath]; } if(is_array($item)) $result = array_merge($result, createList($item, $keySearch, $basePath)); } return $result; } $keySearch = 'a'; $res = createList($array, $keySearch); echo '<pre>'; print_r($res);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Array ( [key] => farm [basePath] => farm ) [1] => Array ( [key] => rabbit [basePath] => farm/horse/rabbit ) )

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:
18.64 ms | 401 KiB | 8 Q