PHP code example of brianium / nomnom

1. Go to this page and download the library: Download brianium/nomnom library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

brianium / nomnom example snippets


$nomnom = new Nomnom(1440000);

//metric conversion to 1.44
$mb = $nomnom->from('B')->to('MB', 2);

$nomnom = new Nomnom(1024);

//binary conversion to 1
$kb = $nomnom->from('KiB')->to('MiB');

//convert a file size
$filesize = new Filesize('/path/to/file.txt');
$mb = $filesize->to('MB');

//returns 1.44
Nomnom::nom(1440000)->from(Nomnom::BYTES)->to(Nomnom::MB, 2);

//factory for Filesize
Nomnom::file('/path/to/file.txt')->to(Nomnom::MB);