Reverse Integer

Solution

Runtime: 0 ms, faster than 100.00% of PHP online submissions for Reverse Integer.
Memory Usage: 15 MB, less than 10.00% of PHP online submissions for Reverse Integer.

LeetCode
class Solution {

    /**
     * @param Integer $x
     * @return Integer
     */
    function reverse($x) {
        if($x>0){
            $out = (int)strrev($x);
            if($out >= 2147483647)
                return 0;
        }
        else{
            $out = (int)("-".str_replace('-','',strrev($x)));
            if($out <= -2147483647)
                return 0;
        }
        return $out;
    }
}