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

$text = "А роза упала на лапу Азора";
$result = "палиндром";

$text = mb_strtolower($text);
$text = str_replace(" ","",$text);
$length = mb_strlen($text);
$halfLength = floor ($length/2);

for ($i=0; $i<=$halfLength;$i++){
	$ch1=mb_substr($text,$i,1);
	$ch2=mb_substr($text,(-1,$i);
if ($ch1==$ch2){
echo "Проверка {$i}-ой буквы: {$ch1} совпадает с {$ch2}\n";
}
elseif($ch1!=$ch2) {
	echo "Не совпадает {$ch1} не совпадает с {$ch2}";
	break;
 }
}