3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testarr = array ( 'advertiser' => array ( 'id' => 135234, 'name' => 'Some Advertiser', 'agency' => array ( 'id' => 137734, 'name' => 'Some Agenecy', 'organisation' => array ( 'id' => 383734, 'name' => 'Some Organisation' ), ) ) ); function getkeypath($arr, $lookup) { if (in_array($lookup, $arr)) { return array($lookup); } else { foreach ($arr as $key => $subarr) { if (is_array($subarr)) { $ret = getkeypath($subarr, $lookup); if ($ret) { $ret[] = $key; return $ret; } } } } return null; } echo '$testarr: ' . "/n"; print_r($testarr); echo '<br>' . 'Organisation: ' . '<br>' . print_r(getkeypath($testarr, '383734'), true) . '<br>';
Output for git.master, git.master_jit, rfc.property-hooks
$testarr: /nArray ( [advertiser] => Array ( [id] => 135234 [name] => Some Advertiser [agency] => Array ( [id] => 137734 [name] => Some Agenecy [organisation] => Array ( [id] => 383734 [name] => Some Organisation ) ) ) ) <br>Organisation: <br>Array ( [0] => 383734 [1] => organisation [2] => agency [3] => advertiser ) <br>

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:
59.93 ms | 402 KiB | 8 Q