3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = array ( 0 => array ( 'id' => '1', 'p_pag' => '0', 'link' => 'Contact', 'children' => array ( 0 => array ( 'id' => '2', 'p_pag' => '1', 'link' => 'Contact-County', 'children' => array ( 0 => array ( 'id' => '3', 'p_pag' => '2', 'link' => 'Contact-Town-1', 'children' => array ( ), ), ), ), ), ), ); $searchId = 3; $link = null; $iterator = new \RecursiveIteratorIterator( new \RecursiveArrayIterator($arr),\RecursiveIteratorIterator::SELF_FIRST ); foreach($iterator as $subarr){ if(is_array($subarr) && array_key_exists('id',$subarr) && $subarr['id'] == $searchId){ $link = $subarr['link']; break; } } echo $link ? $link : 'not found';
Output for git.master_jit, git.master, rfc.property-hooks
Contact-Town-1

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:
48.2 ms | 1249 KiB | 4 Q