- substr: documentation ( source)
- mb_strlen: documentation ( source)
- floor: documentation ( source)
- str_replace: documentation ( source)
- mb_strtolower: documentation ( source)
- mb_internal_encoding: documentation ( source)
<?php
mb_internal_encoding ('utf-8');
$text = "А роза упала на лапу азора";
$result = "палиндром";
$text = mb_strtolower($text);
$text = str_replace (" ", "", $text);
$a = mb_strlen ($text);
$x = floor ($a/2);
for ($i =0 ; $i <=$x; $i++) {
$wordEnd = substr ($x, -1);
$wordStart = substr ($x, 0);
if ($wordEnd != $wordStart){
break;
echo "Не палиндром";
}
}