src/Core/Convert.php
public static function memstring2bytes($memString)
    {
        // Remove  non-unit characters from the size
        $unit = preg_replace('/[^bkmgtpezy]/i', '', $memString);
        // Remove non-numeric characters from the size
        $size = preg_replace('/[^0-9\.\-]/', '', $memString);

        if ($unit) {
            // Find the position of the unit in the ordered string which is the power
            // of magnitude to multiply a kilobyte by
            return (int)round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
        }

        return (int)round($size);
    }
public static function memstring2bytes($memString)
    {
        // Remove  non-unit characters from the size
        $unit = preg_replace('/[^bkmgtpezy]/i', '', $memString);
        // Remove non-numeric characters from the size
        $size = preg_replace('/[^0-9\.\-]/', '', $memString);

        if ($unit) {
            // Find the position of the unit in the ordered string which is the power
            // of magnitude to multiply a kilobyte by
            return (int)round($size * pow(1024, stripos('bkmgtpezy', $unit[0])));
        }

        return (int)round($size);
    }
public static function memstring2bytes ( $ memString ) { // Remove  non-unit characters from the size $ unit = preg_replace ( '/[^bkmgtpezy]/i' , '' , $ memString ) ; // Remove non-numeric characters from the size $ size = preg_replace ( '/[^0-9\.\-]/' , '' , $ memString ) ; if ( $ unit ) { // Find the position of the unit in the ordered string which is the power // of magnitude to multiply a kilobyte by return ( int ) round ( $ size * pow ( 1024 , stripos ( 'bkmgtpezy' , $ unit [ 0 ] ) ) ) ; } return ( int ) round ( $ size ) ; }
Turn a memory string, such as 512M into an actual number of bytes.
Preserves integer values like "1024" or "-1"

@param string $memString A memory limit string, such as "64M"
@return int
Turn a memory string such as 512M into an actual number of bytes . Preserves integer values like 1024 or - 1