3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a['abc']['def']['ghi'] = 'meukee!'; function getArrayValueByKeys(array $array, $key, ...$keys) { if (!isset($array[$key])) throw new Exception; if(is_array($array[$key])) return getArrayValueByKeys($array[$key], ...$keys); return $array[$key]; } function getArrayValueByKeysMS(array $array, array $keys, $depth = 0) { $key = $keys[$depth]; if (!isset($array[$key])) throw new Exception; if(is_array($array[$key])) return getArrayValueByKeysMS($array[$key], $keys, $depth+1); return $array[$key]; } echo getArrayValueByKeys($a, ...['abc', 'def', 'ghi']); echo getArrayValueByKeysMS($a, ['abc', 'def', 'ghi']); echo getArrayValueByKeys($a, ...['ddd', 'def', 'ghi']);
Output for git.master, git.master_jit, rfc.property-hooks
meukee!meukee! Fatal error: Uncaught Exception in /in/01TuQ:8 Stack trace: #0 /in/01TuQ(33): getArrayValueByKeys(Array, 'ddd', 'def', 'ghi') #1 {main} thrown in /in/01TuQ on line 8
Process exited with code 255.

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:
42.56 ms | 401 KiB | 8 Q