Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Palindrome
- {
- public static function isPalindrome($word)
- {
- // Ignore the case
- $word = strtolower($word);
- // length to loop
- $length = strlen($word);
- // array length
- $length--;
- for ($i = 0; $i < ($length/2); $i++) {
- if ($word[$i] != $word[$length-$i]) { //checking string equal
- return false;
- }
- }
- return true;
- }
- }
- echo Palindrome::isPalindrome('Deleveled');
Add Comment
Please, Sign In to add comment