public static function toNumber($str)
    {
        if (is_string($str)) {
            $str = preg_replace("~[^0-9-.]~", "", $str);
        }
        return (strpos($str, ".") === false)
            ? intval($str)
            : floatval($str);
    }
public static function toNumber($str)
    {
        if (is_string($str)) {
            $str = preg_replace("~[^0-9-.]~", "", $str);
        }
        return (strpos($str, ".") === false)
            ? intval($str)
            : floatval($str);
    }
public static function toNumber ( $ str ) { if ( is_string ( $ str ) ) { $ str = preg_replace ( "~[^0-9-.]~" , "" , $ str ) ; } return ( strpos ( $ str , "." ) === false ) ? intval ( $ str ) : floatval ( $ str ) ; }
Convert a string to a number

@param string $str
@return int|float
Convert a string to a number