- substr: documentation ( source)
<?php
function solution($S) {
$length = strlen($S);
if ($length == 0) {
return false;
} elseif ($length == 1) {
return true;
} else {
for ( $i=0; $i < strlen($S); $i++) {
if (substr($S, $i, 1) == substr($S, $length - $i, 1)) {
continue;
} else {
return false;
}
}
}
return true;
}
echo solution('anavolimilovana');
?>