}\r
\r
function convert_app_menu($a,&$b) {\r
- $b['app_menu'][] = '<div class="app-title"><a href="convert">Units Conversion</a></div>'; \r
+ $b['app_menu'][] = '<div class="app-title"><a href="convert">Units Conversion</a></div>';\r
}\r
\r
\r
function convert_content($app) {\r
\r
include("UnitConvertor.php");\r
- \r
+\r
class TP_Converter extends UnitConvertor {\r
function TP_Converter($lang = "en")\r
{\r
} else {\r
$dec_point = '.'; $thousand_sep = ",";\r
}\r
- \r
+\r
$this->UnitConvertor($dec_point , $thousand_sep );\r
\r
} // end func UnitConvertor\r
function find_base_unit($from,$to) {\r
while (list($skey,$sval) = each($this->bases)) {\r
if ($skey == $from || $to == $skey || in_array($to,$sval) || in_array($from,$sval)) {\r
- return $skey; \r
+ return $skey;\r
}\r
}\r
- return false; \r
+ return false;\r
}\r
\r
function getTable($value, $from_unit, $to_unit, $precision) {\r
- \r
+\r
if ($base_unit = $this->find_base_unit($from_unit,$to_unit)) {\r
- \r
- // A baseunit was found now lets convert from -> $base_unit \r
- \r
- $cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision)." ".$base_unit; \r
+\r
+ // A baseunit was found now lets convert from -> $base_unit\r
+\r
+ $cell ['value'] = $this->convert($value, $from_unit, $base_unit, $precision)." ".$base_unit;\r
$cell ['class'] = ($base_unit == $from_unit || $base_unit == $to_unit) ? "framedred": "";\r
$cells[] = $cell;\r
// We now have the base unit and value now lets produce the table;\r
while (list($key,$val) = each($this->bases[$base_unit])) {\r
- $cell ['value'] = $this->convert($value, $from_unit, $val, $precision)." ".$val; \r
+ $cell ['value'] = $this->convert($value, $from_unit, $val, $precision)." ".$val;\r
$cell ['class'] = ($val == $from_unit || $val == $to_unit) ? "framedred": "";\r
$cells[] = $cell;\r
}\r
}\r
$string .= "</tr></table>";\r
return $string;\r
- } \r
- \r
+ }\r
+\r
}\r
}\r
\r
$conv = new TP_Converter('en');\r
\r
\r
-$conversions = array(\r
- 'Temperature'=>array('base' =>'Celsius',\r
- 'conv'=>array(\r
- 'Fahrenheit'=>array('ratio'=>1.8, 'offset'=>32),\r
- 'Kelvin'=>array('ratio'=>1, 'offset'=>273),\r
+$conversions = [\r
+ 'Temperature'=>['base' =>'Celsius',\r
+ 'conv'=>[\r
+ 'Fahrenheit'=>['ratio'=>1.8, 'offset'=>32],\r
+ 'Kelvin'=>['ratio'=>1, 'offset'=>273],\r
'Reaumur'=>0.8\r
- )\r
- ),\r
- 'Weight' => array('base' =>'kg',\r
- 'conv'=>array(\r
+ ]\r
+ ],\r
+ 'Weight' => ['base' =>'kg',\r
+ 'conv'=>[\r
'g'=>1000,\r
'mg'=>1000000,\r
't'=>0.001,\r
'oz'=>35.274,\r
'lb'=>2.2046,\r
'cwt(UK)' => 0.019684,\r
- 'cwt(US)' => 0.022046, \r
+ 'cwt(US)' => 0.022046,\r
'ton (US)' => 0.0011023,\r
'ton (UK)' => 0.0009842\r
- )\r
- ),\r
- 'Distance' => array('base' =>'km',\r
- 'conv'=>array(\r
+ ]\r
+ ],\r
+ 'Distance' => ['base' =>'km',\r
+ 'conv'=>[\r
'm'=>1000,\r
'dm'=>10000,\r
'cm'=>100000,\r
'yd'=>1093.6,\r
'furlong'=>4.970969537898672,\r
'fathom'=>546.8066491688539\r
- )\r
- ),\r
- 'Area' => array('base' =>'km 2',\r
- 'conv'=>array( \r
+ ]\r
+ ],\r
+ 'Area' => ['base' =>'km 2',\r
+ 'conv'=>[\r
'ha'=>100,\r
'acre'=>247.105,\r
'm 2'=>pow(1000,2),\r
'dm 2'=>pow(10000,2),\r
'cm 2'=>pow(100000,2),\r
- 'mm 2'=>pow(1000000,2), \r
+ 'mm 2'=>pow(1000000,2),\r
'mile 2'=>pow(0.62137,2),\r
'naut.miles 2'=>pow(0.53996,2),\r
'in 2'=>pow(39370,2),\r
'ft 2'=>pow(3280.8,2),\r
'yd 2'=>pow(1093.6,2),\r
- )\r
- ),\r
- 'Volume' => array('base' =>'m 3',\r
- 'conv'=>array(\r
+ ]\r
+ ],\r
+ 'Volume' => ['base' =>'m 3',\r
+ 'conv'=>[\r
'in 3'=>61023.6,\r
'ft 3'=>35.315,\r
'cm 3'=>pow(10,6),\r
'fl oz' => 33814.02,\r
'tablespoon' => 67628.04,\r
'teaspoon' => 202884.1,\r
- 'pt (UK)'=>1000/0.56826, \r
+ 'pt (UK)'=>1000/0.56826,\r
'barrel petroleum'=>1000/158.99,\r
- 'Register Tons'=>2.832, \r
+ 'Register Tons'=>2.832,\r
'Ocean Tons'=>1.1327\r
- )\r
- ),\r
- 'Speed' =>array('base' =>'kmph',\r
- 'conv'=>array(\r
+ ]\r
+ ],\r
+ 'Speed' =>['base' =>'kmph',\r
+ 'conv'=>[\r
'mps'=>0.0001726031,\r
'milesph'=>0.62137,\r
'knots'=>0.53996,\r
'mach STP'=>0.0008380431,\r
'c (warp)'=>9.265669e-10\r
- )\r
- )\r
-);\r
+ ]\r
+ ]\r
+];\r
\r
\r
while (list($key,$val) = each($conversions)) {\r
$o .= '</select>';\r
\r
$o .= '<input type="submit" name="Submit" value="Submit" /></form>';\r
- \r
+\r
return $o;\r
}\r