<?php

error_reporting(-1);
mb_internal_encoding('utf-8');
$originaltext = 'А роЗа Упала на лапу Азора';
/*switching all the letters to the lowercase*/
$lowercasedtext = mb_strtolower($originaltext);
/*checking the lowercased text*/
echo "$lowercasedtext\n";
/*making the text without spaces*/
$empty = '';
$lowercasedtext = str_replace(' ',$empty,$lowercasedtext);
/*checking the text without spaces*/
echo "$lowercasedtext\n";
/*comparing the symbols from both ends*/
$half = floor(mb_strlen($lowercasedtext)/2);
echo $half."\n";
for ($j=0; $j <= $half; $j++) {
    /*returning the symbols to be compared*/
    echo mb_substr($lowercasedtext, $j, 1) . " and " . mb_substr($lowercasedtext, mb_strlen($lowercasedtext) - $j-1, 1)."\n";
    /*comparing the returned symbols*/
    if (mb_substr($lowercasedtext,$j,1) == mb_substr($lowercasedtext,mb_strlen($lowercasedtext)-$j-1,1)) {
        echo "noice\n";
        /*checking whether the cycle has reached it's end*/
        if ($j == $half){
            echo "congrats, this word's  a fucking palindrome";
        }
    }
    else {
        echo "tough luck, m8";
        break;
    }
}

?>
