note 75449 deleted from features.file-upload by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: djcassis gmail com 

----

Here is the fastest way to retreive an integer size from a value coming from your php.ini file :
<?php
function ini_get_size($sName)
{
    $sSize = ini_get($sName);
    $sUnit = substr($sSize, -1);
    $iSize = (int) substr($sSize, 0, -1);
    switch (strtoupper($sUnit))
    {
        case 'Y' : $iSize *= 1024; // Yotta
        case 'Z' : $iSize *= 1024; // Zetta
        case 'E' : $iSize *= 1024; // Exa
        case 'P' : $iSize *= 1024; // Peta
        case 'T' : $iSize *= 1024; // Tera
        case 'G' : $iSize *= 1024; // Giga
        case 'M' : $iSize *= 1024; // Mega
        case 'K' : $iSize *= 1024; // kilo
    };
    return $iSize;
}

// example
echo ini_get_size('post_max_size'); // e.g. 8388608 instead of 8M
?>
Let's just hope PHP will live long enough to see petabytes and yottabytes ;o)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.