- substr: documentation ( source)
- array_shift: documentation ( source)
<?php
function rev($str) {
if ( ! $str ) {
return;
}
return rev(substr($str,1)) . $str{0};
}
function sum($arr) {
if ( empty($arr) ) {
return;
}
return sum(array_shift($arr)) + $arr[0];
}
$a = array(5,4,7,8,9,3);
echo sum($a);
echo rev('hola mundos ninos');