3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = [ 1 => ['Hello' => 'this is a nested hello!'], 'Hello' => 'this is a root hello!']; function getValue($root, $i = null) { $_t = isset($root[$i]) ? $root[$i] : $root; return isset($_t['Hello']) ? $_t['Hello'] : ''; } echo getValue($input); echo getValue($input, 1); echo getValue($input, 2);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
170.25 ms | 2322 KiB | 12 Q