Guest User

Untitled

a guest
Jan 21st, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. <?php
  2. class Palindrome
  3. {
  4. public static function isPalindrome($word)
  5. {
  6. // Ignore the case
  7. $word = strtolower($word);
  8. // length to loop
  9. $length = strlen($word);
  10. // array length
  11. $length--;
  12. for ($i = 0; $i < ($length/2); $i++) {
  13. if ($word[$i] != $word[$length-$i]) { //checking string equal
  14. return false;
  15. }
  16. }
  17.  
  18. return true;
  19. }
  20. }
  21.  
  22. echo Palindrome::isPalindrome('Deleveled');
Add Comment
Please, Sign In to add comment