1. Go to this page and download the library: Download teamchallengeapps/distance 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/ */
use TeamChallengeApps\Distance\Distance;
$meters = new Distance(100, 'meters');
$km = new Distance(10.5, 'kilometers');
$miles = new Distance(10, 'miles');
$steps = new Distance(10000, 'footsteps');
$distance new Distance(0);
if ($distance->isEmpty()) {
//
}
if ($distance->isZero()) {
}
$distance = new Distance(10);
$total = new Distance(100);
if ($distance->lt($total)) {
// Less than
}
if ($distance->lte($total)) {
// Less than or equal
}
if ($distance->gt($total)) {
// Greater than
}
if ($distance->gte($total)) {
// Greater than or equal
}
$distance = new Distance(10);
$total = new Distance(100);
$percentage = $distance->percentageOf($total); // 10
$distance = new Distance(150);
$total = new Distance(100);
$percentage = $distance->percentageOf($total); // 100
$percentage = $distance->percentageOf($total, false); // 150
$total = new Distance(1000);
$logged = new Distance(10);
$total->increment($logged);
echo $total->value; // 1010
$total = new Distance(1010);
$redeemed = new Distance(10);
$total->decrement($logged);
echo $total->value; // 1000