fork(2) download
  1. <?php
  2.  
  3. $originaltext = 'А роЗа Упала на лапу Азора';
  4. /*switching all the letters to the lowercase*/
  5. $lowercasedtext = mb_strtolower($originaltext);
  6. /*checking the lowercased text*/
  7. echo "$lowercasedtext\n";
  8. /*making the text without spaces*/
  9. $empty = '';
  10. $lowercasedtext = str_replace(' ',$empty,$lowercasedtext);
  11. /*checking the text without spaces*/
  12. echo "$lowercasedtext\n";
  13. /*comparing the symbols from both ends*/
  14. $half = floor(mb_strlen($lowercasedtext)/2);
  15. echo $half."\n";
  16. for ($j=0; $j <= $half; $j++) {
  17. /*returning the symbols to be compared*/
  18. echo mb_substr($lowercasedtext, $j, 1) . " and " . mb_substr($lowercasedtext, mb_strlen($lowercasedtext) - $j-1, 1)."\n";
  19. /*comparing the returned symbols*/
  20. if (mb_substr($lowercasedtext,$j,1) == mb_substr($lowercasedtext,mb_strlen($lowercasedtext)-$j-1,1)) {
  21. echo "noice\n";
  22. /*checking whether the cycle has reached it's end*/
  23. if ($j == $half){
  24. echo "congrats, this word's a fucking palindrome";
  25. }
  26. }
  27. else {
  28. echo "tough luck, m8";
  29. break;
  30. }
  31. }
  32.  
  33. ?>
  34.  
Success #stdin #stdout 0.02s 24448KB
stdin
Standard input is empty
stdout
а роза упала на лапу азора
арозаупаланалапуазора
10
а and а
noice
р and р
noice
о and о
noice
з and з
noice
а and а
noice
у and у
noice
п and п
noice
а and а
noice
л and л
noice
а and а
noice
н and н
noice
congrats, this word's  a fucking palindrome