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

$j = strlen ($word)-1;
$pal = true;

for ($i = 0; $i < strlen($word)/2; ++$i, --$j) {

    // skip spaces
    while ($word[$i] === " ") {$j++;}
    while ($word[$j] === " ") {$i--;}

    echo "$word[$i]== $word[$j]\n";
    if ($word[$i] = $word[$j])    {
        $pal = false;
        break;
        }
}

if ($pal) print "no"; else print "yes";