3v4l.org

run code in 300+ PHP versions simultaneously
<?php $testarr = array( 'advertiser' => array( 'id'=>345343, 'name'=>'Advertiser123', 'agency' => array( 'id'=>345343, 'name'=>'Agency456', 'organisation' => array( 'id'=>223334, 'name'=>'Organisation456' ) ) ) ); 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 "\n" . '7: ' . "\n" . print_r(getkeypath($testarr, 223334), true) . "\n";
Output for git.master, git.master_jit, rfc.property-hooks
$testarr: Array ( [advertiser] => Array ( [id] => 345343 [name] => Advertiser123 [agency] => Array ( [id] => 345343 [name] => Agency456 [organisation] => Array ( [id] => 223334 [name] => Organisation456 ) ) ) ) 7: Array ( [0] => 223334 [1] => organisation [2] => agency [3] => advertiser )

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.77 ms | 402 KiB | 8 Q