With this code:
function lookForTheA($str, $pos) {
if ($str[$pos] == 'A') {
return 'is in position: '.$pos;
} else {
$pos++;
return lookForTheA($str, $pos);
}
}
$str = 'BBBBBBBBBBBBBBBBBBBBBBA';
$res = lookForTheA($str, 0);
echo $res;
I need to know if the second return (line 6) is needed. If it's a good way to resolve it.