PHP code example of becker / conversion

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

    

becker / conversion example snippets


composer 

//config/app.php

/*
 * Package Service Providers...
 */

Becker\Conversion\ConversionServiceProvider::class

//...

'Conversion'  => Becker\Conversion\Facades\Conversion::class

Conversion::convert($value, 'type')->to('another_type');

Conversion::convert(1, 'megabyte')->to('kilobyte');
// 1.024,00 (two decimal places)

Conversion::convert(1000, 'millimeter')->to('centimeter');

Conversion::convert(1, 'kilogram')->to('gram');

Conversion::convert($value, 'type')->to('another_type')
->format(int decimal, 'decimal place modifier', 'thousand place modifier');

Conversion::convert(1, 'megabyte')->to('kilobyte')->format(0,'.',',');
// 1,024 (no decimal place)