Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php convert bytes to mb

<?php
// Snippet from PHP Share: http://www.phpshare.org

    function formatSizeUnits($bytes)
    {
        if ($bytes >= 1073741824)
        {
            $bytes = number_format($bytes / 1073741824, 2) . ' GB';
        }
        elseif ($bytes >= 1048576)
        {
            $bytes = number_format($bytes / 1048576, 2) . ' MB';
        }
        elseif ($bytes >= 1024)
        {
            $bytes = number_format($bytes / 1024, 2) . ' KB';
        }
        elseif ($bytes > 1)
        {
            $bytes = $bytes . ' bytes';
        }
        elseif ($bytes == 1)
        {
            $bytes = $bytes . ' byte';
        }
        else
        {
            $bytes = '0 bytes';
        }

        return $bytes;
}
?>
Comment

php convert mb to bytes

function toByteSize($p_sFormatted) {
    $aUnits = array('B'=>0, 'KB'=>1, 'MB'=>2, 'GB'=>3, 'TB'=>4, 'PB'=>5, 'EB'=>6, 'ZB'=>7, 'YB'=>8);
    $sUnit = strtoupper(trim(substr($p_sFormatted, -2)));
    if (intval($sUnit) !== 0) {
        $sUnit = 'B';
    }
    if (!in_array($sUnit, array_keys($aUnits))) {
        return false;
    }
    $iUnits = trim(substr($p_sFormatted, 0, strlen($p_sFormatted) - 2));
    if (!intval($iUnits) == $iUnits) {
        return false;
    }
    return $iUnits * pow(1024, $aUnits[$sUnit]);
}
Comment

PREVIOUS NEXT
Code Example
Php :: php random 5 digit number 
Php :: save array in mysql php 
Php :: laravel route group name 
Php :: laravel old request radio check 
Php :: Allowed memory size of 1610612736 bytes exhausted laravel 
Php :: php convert array to number 
Php :: php random string 
Php :: php read csv file into array 
Php :: php json_encode 
Php :: php array longest string 
Php :: laravel 8 change password 
Php :: laravel with has 
Php :: return response not found laravel api response 
Php :: wordpress require file from plugins folder 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52 
Php :: php redirect 404 page not found 
Php :: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://vtl-lab.com/VN/crecc-cms/api/member/register.json. (Reason: CORS request did not succeed). 
Php :: php array merge skip diplicate 
Php :: codeigniter redirect 
Php :: laravel count group by date 
Php :: http error 500 - php file 
Php :: check which database connect laravel 
Php :: php money_format currency symbol 
Php :: laravel get all users except role spatie 
Php :: flutter network image svg 
Php :: register_post_type wordpress 
Php :: Convert String to Date and Date-Time in PHP 
Php :: php zeilenumbruch 
Php :: log data into file php 
Php :: php cloudflare get country from IP 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =