<?php
error_reporting(-1);
mb_internal_encoding('utf-8');

$text = "А роза упала на лапу Азора";
$noSpaces = mb_strtolower(str_replace(" ", "", $text));
$halfLength = floor((mb_strlen($noSpaces)) / 2);
$checkCount = 0;

for ($i = 1; $i <= $halfLength; $i++) {
    $leftSide = mb_substr($noSpaces, $i - 1, 1);
    $rightSide = mb_substr($noSpaces, $i * (-1), 1);
    if ($leftSide == $rightSide) {
        $checkCount++;
    }
}
if ($checkCount == $halfLength) {
    echo "Palindrome";
} else {
    echo "Not a palindrome";
}
