gdr2_Units

Class for the conversion of values with different units.


function __construct()

Runs the initialization of the units convertion arrays.


public init()

Initialization of conversion arrays.


public get_values($name)

  • $name: name of the unit.

Get values for the a unit.

Function returns: array unit values.


public get_units($name)

Get the list of units.

Function returns: array associative array with units.


public from_base($name, $value, $to)

  • $name: name of the unit type.
  • $value: value to convert.
  • $to: name of the unit to convert into.

Convert value from base unit value to selected unit.

Function returns: number converted value.


public to_base($name, $value, $from)

  • $name: name of the unit type.
  • $value: value to convert.
  • $from: name of the unit to convert from.

Convert value to base unit value from selected unit.

Function returns: number converted value.


public convert($name, $value, $from, $to)

  • $name: name of the unit type.
  • $value: value to convert.
  • $from: name of the unit to convert from.
  • $to: name of the unit to convert into.

Convert value for unit.

Function returns: number converted value.

Comments

Leave a Reply