PHP code example of sirmekus / otu

1. Go to this page and download the library: Download sirmekus/otu 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/ */

    

sirmekus / otu example snippets


composer 



use Emmy\App\Assistant\Otu;

$converted = Otu::convertToNumber("89k");
//Output: 89000

$converted = Otu::convertToNumber("89.54k");
//Output: 89540

$converted = Otu::convertToNumber("89.5k");
//Output: 89500

$converted = Otu::convertToNumber("50.6M");
//Output: 50600000

//etc.

$converted = Otu::format("50.6M");
//Output: 50,600,000.00



use Emmy\App\Assistant\Otu;

$converted = Otu::abbreviate(290450);
//Output: 290.5K

$converted = Otu::abbreviate(290450, round:false);
//Output (prevent rounding up "decimal" part): 290.4K

//Specify output in 2 'decimal' places
$converted = Otu::abbreviate(290456,2);
//Output: 290.46K

$converted = Otu::abbreviate(290450, useUnit:false);
//Output (full specification of the magnitude): 290.5 thousand