9. Palindrome Number

class Solution {

    /**
     * @param Integer $x
     * @return Boolean
     */
    function isPalindrome($x) {
        $words = str_split($x);
        $head = 0;
        $tail = count($words) - 1;
        while ($tail >= 1) {
         if ($words[$head] != $words[$tail]){
             return false;
         }
         $head++;
         $tail--;
        }

        return true;
    }
}

Last updated