3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?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 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.38
Parse error: syntax error, unexpected '<' in /in/pdUbZ on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '<' in /in/pdUbZ on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/pdUbZ on line 3
Process exited with code 255.

preferences:
235.72 ms | 1395 KiB | 128 Q