fork download
  1. <?php
  2. $word = "malayal";
  3.  
  4. $j = strlen ($word)-1;
  5. $pal = true;
  6.  
  7. for ($i = 0; $i < strlen($word)/2; ++$i, --$j) {
  8.  
  9. // skip spaces
  10. while ($word[$i] === " ") {$j++;}
  11. while ($word[$j] === " ") {$i--;}
  12.  
  13. echo "$word[$i]== $word[$j]\n";
  14. if ($word[$i] = $word[$j]) {
  15. $pal = false;
  16. break;
  17. }
  18. }
  19.  
  20. if ($pal) print "no"; else print "yes";
  21. ?>
  22.  
Success #stdin #stdout 0.02s 25500KB
stdin
Standard input is empty
stdout
m== l
yes