pastebin

Paste Search Dynamic
Recent pastes
word
  1. <?php
  2.  
  3. $word = "malayal";
  4.  
  5. $j = strlen ($word)-1;
  6. $pal = true;
  7.  
  8. for ($i = 0; $i < strlen($word)/2; ++$i, --$j) {
  9.  
  10.     // skip spaces
  11.     while ($word[$i] === " ") {$i++;}
  12.     while ($word[$j] === " ") {$j--;}
  13.  
  14.     echo "$word[$i]== $word[$j]\n";
  15.     if ($word[$i] == $word[$j])    {
  16.         $pal = true;
  17.         break;
  18.         }
  19. }
  20.  
  21. if ($pal) print "yes"; else print "no";
  22.  
  23. ?>
Parsed in 0.013 seconds