public static function convert($string)
    {
        $sign = "(?P<sign>[-\+])?";
        $digits = "(?P<digits>\d*)";
        $separator = "(?P<separator>[.,])?";
        $decimals = "(?P<decimal1>\d)?(?P<decimal2>\d)?(?P<remaining_decimals>\d)*";
        $pattern = "/^".$sign.$digits.$separator.$decimals."$/";

        if (!preg_match($pattern, trim($string), $matches)) {
            throw new InvalidArgumentException("The value could not be parsed as money");
        }

        $units = $matches['sign'] == "-" ? "-" : "";
        $units .= $matches['digits'];
        $units .= isset($matches['decimal1']) ? $matches['decimal1'] : "0";
        $units .= isset($matches['decimal2']) ? $matches['decimal2'] : "0";

        return (int) $units;
    }
public static function convert($string)
    {
        $sign = "(?P<sign>[-\+])?";
        $digits = "(?P<digits>\d*)";
        $separator = "(?P<separator>[.,])?";
        $decimals = "(?P<decimal1>\d)?(?P<decimal2>\d)?(?P<remaining_decimals>\d)*";
        $pattern = "/^".$sign.$digits.$separator.$decimals."$/";

        if (!preg_match($pattern, trim($string), $matches)) {
            throw new InvalidArgumentException("The value could not be parsed as money");
        }

        $units = $matches['sign'] == "-" ? "-" : "";
        $units .= $matches['digits'];
        $units .= isset($matches['decimal1']) ? $matches['decimal1'] : "0";
        $units .= isset($matches['decimal2']) ? $matches['decimal2'] : "0";

        return (int) $units;
    }
public static function convert ( $ string ) { $ sign = "(?P<sign>[-\+])?" ; $ digits = "(?P<digits>\d*)" ; $ separator = "(?P<separator>[.,])?" ; $ decimals = "(?P<decimal1>\d)?(?P<decimal2>\d)?(?P<remaining_decimals>\d)*" ; $ pattern = "/^" . $ sign . $ digits . $ separator . $ decimals . "$/" ; if ( ! preg_match ( $ pattern , trim ( $ string ) , $ matches ) ) { throw new InvalidArgumentException ( "The value could not be parsed as money" ) ; } $ units = $ matches [ 'sign' ] == "-" ? "-" : "" ; $ units .= $ matches [ 'digits' ] ; $ units .= isset ( $ matches [ 'decimal1' ] ) ? $ matches [ 'decimal1' ] : "0" ; $ units .= isset ( $ matches [ 'decimal2' ] ) ? $ matches [ 'decimal2' ] : "0" ; return ( int ) $ units ; }
Converts a string value with an amount into an integer.
Supports up to 5 decimals points.

Credit goes to the mathiasverraes/money library

@param $string
@return int
@throws InvalidArgumentException
Converts a string value with an amount into an integer . Supports up to 5 decimals points .