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

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

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

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

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