3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'entity_id' => 5740, 'parent_id' => 5739, 'label' => 'Sports', 'name' => 'sports', 'children' => [ [ 'entity_id' => 5754, 'parent_id' => 5740, 'label' => 'Badminton', 'name' => 'badminton', 'children' => [ [ 'entity_id' => 5756, 'parent_id' => 5754, 'label' => 'Tournaments', 'name' => 'tournaments', ] ], ] ], ]; function labelSearch(array $array, string $label): array { foreach ($array as $item) { if ($item['label'] === $label) { unset($item['children']); return $item; } if (isset($item['children'])) { $result = labelSearch($item['children'], $label); if ($result) { return $result; } } } return null; } var_export(labelSearch([$array], 'Badminton'));
Output for git.master, git.master_jit
array ( 'entity_id' => 5754, 'parent_id' => 5740, 'label' => 'Badminton', 'name' => 'badminton', )

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