Distance is PHP 5.3 and PHP 5.4 compatible library that allows you to convert from one distance to another. Common metric and US distances are provided, the interface allows you to set a value and mileage unit and convert to a different mileage unit.


use Frost\Distance;
$distance = new Distance();
$value = $distance->convertTo('km');


As a runner, I always like to be able to change from miles to km and km to miles; so for a running project I've been working on I decided to write this library. I deemed it rather short sited to just provide a conversion from one measurement, so I added a few more to the list. Now it will handle most if not all common distance measurement units. ## Units Here is a list of the units that are available:

  • mi - miles
  • ft - feet
  • in - inches
  • km - kilometers
  • m - meters
  • cm - centimeters
  • mm - millimeters

Where can I find it?

It is a available on github - it's also available if you use composer via Packagist