PHP code example of olifolkerd / convertor

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

    

olifolkerd / convertor example snippets


$simpleConvertor = new Convertor(10, "m");
$simpleConvertor->to("ft"); //returns converted value

//using the default file in `src/Config/Units.php`:
$c=new Convertor(100,"mps");
//using another file somewhere in the project:
$c=new Convertor(100,"mps",'/path/to/my/own/Units.php');
//using the name of the file in conf:
$c=new Convertor(100,"mps",'BaseUnits.php');
//define own units inline
$arr = [
    "m" => array("base" => "m", "conversion" => 1),
    "km" => array("base" => "m", "conversion" => 1000),
];

$c = new Convertor(1, 'm', $arr);