PHP Classes

File: docs/conversion.md

Recommend this page to a friend!
  Classes of Eric Sizemore   Utility   docs/conversion.md   Download  
File: docs/conversion.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Utility
Collection of various PHP utility functions
Author: By
Last change:
Date: 9 months ago
Size: 3,865 bytes
 

Contents

Class file image Download

Conversion

Esi\Utility\Conversion

  • fahrenheitToCelsius(float $fahrenheit, bool $rounded = true, int $precision = 2): float;
  • celsiusToFahrenheit(float $celsius, bool $rounded = true, int $precision = 2): float;
  • celsiusToKelvin(float $celsius, bool $rounded = true, int $precision = 2): float;
  • kelvinToCelsius(float $kelvin, bool $rounded = true, int $precision = 2): float;
  • fahrenheitToKelvin(float $fahrenheit, bool $rounded = true, int $precision = 2): float;
  • kelvinToFahrenheit(float $kelvin, bool $rounded = true, int $precision = 2): float;
  • fahrenheitToRankine(float $fahrenheit, bool $rounded = true, int $precision = 2): float;
  • rankineToFahrenheit(float $rankine, bool $rounded = true, int $precision = 2): float;
  • celsiusToRankine(float $celsius, bool $rounded = true, int $precision = 2): float;
  • rankineToCelsius(float $rankine, bool $rounded = true, int $precision = 2): float;
  • kelvinToRankine(float $kelvin, bool $rounded = true, int $precision = 2): float;
  • rankineToKelvin(float $rankine, bool $rounded = true, int $precision = 2): float;
  • haversineDistance(int|float $startingLatitude, int|float $startingLongitude, int|float $endingLatitude, int|float $endingLongitude, int $precision = 0): array;

fahrenheitToCelsius

Convert Fahrenheit (Fº) To Celsius (Cº)

use Esi\Utility\Conversion;

echo Conversion::fahrenheitToCelsius(74); // 23.33

celsiusToFahrenheit

Convert Celsius (Cº) To Fahrenheit (Fº)

use Esi\Utility\Conversion;

echo Conversion::celsiusToFahrenheit(23.33); // 73.99

celsiusToKelvin

Convert Celsius (Cº) To Kelvin (K)

use Esi\Utility\Conversion;

echo Conversion::celsiusToKelvin(23.33); // 296.48

kelvinToCelsius

Convert Kelvin (K) To Celsius (Cº)

use Esi\Utility\Conversion;

echo Conversion::kelvinToCelsius(296.48); // 23.33

fahrenheitToKelvin

Convert Fahrenheit (Fº) To Kelvin (K)

use Esi\Utility\Conversion;

echo Conversion::fahrenheitToKelvin(74)); // 296.48

kelvinToFahrenheit

Convert Kelvin (K) To Fahrenheit (Fº)

use Esi\Utility\Conversion;

echo Conversion::kelvinToFahrenheit(296.48); // 73.99

fahrenheitToRankine

Convert Fahrenheit (Fº) To Rankine (ºR)

use Esi\Utility\Conversion;

echo Conversion::fahrenheitToRankine(74); // 533.67

rankineToFahrenheit

Convert Rankine (ºR) To Fahrenheit (Fº)

use Esi\Utility\Conversion;

echo Conversion::rankineToFahrenheit(533.67); // 74.0

celsiusToRankine

Convert Celsius (Cº) To Rankine (ºR)

use Esi\Utility\Conversion;

echo Conversion::celsiusToRankine(30); // 545.67

rankineToCelsius

Convert Rankine (ºR) To Celsius (Cº)

use Esi\Utility\Conversion;

echo Conversion::rankineToCelsius(545.67); // 30.0

kelvinToRankine

Convert Kelvin (K) To Rankine (ºR)

use Esi\Utility\Conversion;

echo Conversion::kelvinToRankine(130); // 234.0

rankineToKelvin

Convert Rankine (ºR) To Kelvin (K)

use Esi\Utility\Conversion;

echo Conversion::rankineToKelvin(234.0); // 130.0

haversineDistance

Calculate the distance between two points using the Haversine Formula.

See Haversine_formula#Formulation.

use Esi\Utility\Conversion;

$lat1 = 37.774_9;
$lon1 = -122.419_4;
$lat2 = 34.052_2;
$lon2 = -118.243_7;

$result = Conversion::haversineDistance($lat1, $lon1, $lat2, $lon2);

print_r($result);

/*
Array
(
    [meters] => 559,119
    [kilometers] => 559
    [miles] => 347
)
*/