Swat/SwatString.php
public static function toFloat($string)
    {
        $lc = localeconv();

        $string = self::parseNegativeNotation($string);

        // change all locale formatting to numeric formatting
        $remove_parts = array(
            $lc['decimal_point'] => '.',
            $lc['positive_sign'] => '',
            $lc['thousands_sep'] => ''
        );

        $value = str_replace(
            array_keys($remove_parts),
            array_values($remove_parts),
            $string
        );

        // note: This might be done better with a regexp, though
        // checking too closely how well a number matches its locale
        // formatting could become annoying too. i.e. if 1000 was
        // rejected because it wasn't formatted 1,000

        return is_numeric($value) ? floatval($value) : null;
    }
public static function toFloat($string)
    {
        $lc = localeconv();

        $string = self::parseNegativeNotation($string);

        // change all locale formatting to numeric formatting
        $remove_parts = array(
            $lc['decimal_point'] => '.',
            $lc['positive_sign'] => '',
            $lc['thousands_sep'] => ''
        );

        $value = str_replace(
            array_keys($remove_parts),
            array_values($remove_parts),
            $string
        );

        // note: This might be done better with a regexp, though
        // checking too closely how well a number matches its locale
        // formatting could become annoying too. i.e. if 1000 was
        // rejected because it wasn't formatted 1,000

        return is_numeric($value) ? floatval($value) : null;
    }
public static function toFloat ( $ string ) { $ lc = localeconv ( ) ; $ string = self :: parseNegativeNotation ( $ string ) ; // change all locale formatting to numeric formatting $ remove_parts = array ( $ lc [ 'decimal_point' ] => '.' , $ lc [ 'positive_sign' ] => '' , $ lc [ 'thousands_sep' ] => '' ) ; $ value = str_replace ( array_keys ( $ remove_parts ) , array_values ( $ remove_parts ) , $ string ) ; // note: This might be done better with a regexp, though // checking too closely how well a number matches its locale // formatting could become annoying too. i.e. if 1000 was // rejected because it wasn't formatted 1,000 return is_numeric ( $ value ) ? floatval ( $ value ) : null ; }
Convert a locale-formatted number and return it as an float.

If the string is not an float, the method returns null.

@param string $string the string to convert.

@return float The converted value.
Convert a locale - formatted number and return it as an float .