private static function discardDecimalDigitsZero($amount, $minimumDecimalDigits = 0)
    {
        if (false !== strpos($amount, '.')) {
            while ('0' == substr($amount, -1)) {
                $amount = substr($amount, 0, -1);
            }

            if ('.' == substr($amount, -1)) {
                $amount = substr($amount, 0, -1);
            }
        }

        if ($minimumDecimalDigits > 0) {
            if (false === strpos($amount, '.')) {
                $amount .= '.';
            }

            $currentDecimalDigits = strlen(substr($amount, strpos($amount, '.') + 1));
            $minimumDecimalDigits -= $currentDecimalDigits;

            while ($minimumDecimalDigits > 0) {
                $amount .= '0';
                $minimumDecimalDigits--;
            }
        }

        return $amount;
    }
private static function discardDecimalDigitsZero($amount, $minimumDecimalDigits = 0)
    {
        if (false !== strpos($amount, '.')) {
            while ('0' == substr($amount, -1)) {
                $amount = substr($amount, 0, -1);
            }

            if ('.' == substr($amount, -1)) {
                $amount = substr($amount, 0, -1);
            }
        }

        if ($minimumDecimalDigits > 0) {
            if (false === strpos($amount, '.')) {
                $amount .= '.';
            }

            $currentDecimalDigits = strlen(substr($amount, strpos($amount, '.') + 1));
            $minimumDecimalDigits -= $currentDecimalDigits;

            while ($minimumDecimalDigits > 0) {
                $amount .= '0';
                $minimumDecimalDigits--;
            }
        }

        return $amount;
    }
private static function discardDecimalDigitsZero ( $ amount , $ minimumDecimalDigits = 0 ) { if ( false !== strpos ( $ amount , '.' ) ) { while ( '0' == substr ( $ amount , - 1 ) ) { $ amount = substr ( $ amount , 0 , - 1 ) ; } if ( '.' == substr ( $ amount , - 1 ) ) { $ amount = substr ( $ amount , 0 , - 1 ) ; } } if ( $ minimumDecimalDigits > 0 ) { if ( false === strpos ( $ amount , '.' ) ) { $ amount .= '.' ; } $ currentDecimalDigits = strlen ( substr ( $ amount , strpos ( $ amount , '.' ) + 1 ) ) ; $ minimumDecimalDigits -= $ currentDecimalDigits ; while ( $ minimumDecimalDigits > 0 ) { $ amount .= '0' ; $ minimumDecimalDigits -- ; } } return $ amount ; }
Remove trailing zeros up to and including the decimal point.

@param string $amount               the amount to process
@param int    $minimumDecimalDigits the number of decimal digits that has to remain under all circumstances

@return string
Remove trailing zeros up to and including the decimal point .