<?php
function sum($arr) {
if ( empty($arr) ) {
return;
}
return $arr[0] + sum(array_slice($arr, 1));
}
function rev($str) {
if ( ! $str ) {
return;
}
return rev(substr($str,1)) . $str{0};
}
echo sum(array(1,2,3,4,5));
echo rev('hola mundo');
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- Fatal error: Array and string offset access syntax with curly braces is no longer supported in /in/ZjH9j on line 14
Process exited with code 255. - Output for 7.4.0 - 7.4.33
- Deprecated: Array and string offset access syntax with curly braces is deprecated in /in/ZjH9j on line 14
15odnum aloh
- Output for 5.3.7 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
- 15odnum aloh
preferences:
183.03 ms | 403 KiB | 282 Q