Paste Search Dynamic
Recent pastes
word pal
  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] === " ") {$i++;}
  11.     while ($word[$j] === " ") {$j--;}
  12.  
  13.     echo "$word[$i]== $word[$j]n";
  14.     if ($word[$i] == $word[$j])    {
  15.         $pal = true;
  16.         break;
  17.         }
  18. }
  19.  
  20. if ($pal) print "yes"; else print "no";
  21.  
  22. ?>
Parsed in 0.015 seconds