fork download
  1. <?php
  2.  
  3. $originaltext = 'Aaa BbB Ccc cc Cbb bA aa';
  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. for ($i=0; $i<=strlen($lowercasedtext);$i++) {if (mb_substr($lowercasedtext,$i,1) != $empty) {
  11. $without = $without.mb_substr($lowercasedtext,$i,1);
  12. }
  13. }
  14. /*checking the text without spaces*/
  15. echo "$without\n";
  16. /*comparing the symbols from both ends*/
  17. $half = floor(strlen($without)/2);
  18. for ($ii=0; $ii <= $half; $ii++){
  19. if (mb_substr($without,$ii,1) == mb_substr($without, strlen($without)-$ii-1,1)) {
  20. echo "$ii th letter is checked\n";
  21. /*checking whether the comparison is done all over the word*/
  22. if ($ii == $half){
  23. echo "this word is a fucking PALINDROME, congrats, m8";
  24. }
  25. }
  26. else {
  27. echo "you dun goofd m8";
  28. break;
  29. }
  30. }
  31.  
  32. ?>
  33.  
Success #stdin #stdout #stderr 0.02s 24448KB
stdin
Standard input is empty
stdout
aaa bbb ccc cc cbb ba aa
aaabbbccccccbbbaaa
0 th letter is checked
1 th letter is checked
2 th letter is checked
3 th letter is checked
4 th letter is checked
5 th letter is checked
6 th letter is checked
7 th letter is checked
8 th letter is checked
9 th letter is checked
this word is a fucking PALINDROME, congrats, m8
stderr
PHP Notice:  Undefined variable: without in /home/hz6bPR/prog.php on line 12