本文整理汇总了PHP中Unit::convert方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::convert方法的具体用法?PHP Unit::convert怎么用?PHP Unit::convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::convert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toRoman
protected function toRoman($number)
{
$u = new Unit();
if ($number % $this->numberUnit == 0) {
return $this->hundred[$number / $this->numberUnit - 1];
} else {
return $this->hundred[$number / $this->numberUnit - 1] . $u->convert($number % $this->numberUnit);
}
}
示例2: amountIn
/**
* Standardize and calculate the total of multiple weights
*
* It's probably faster in theory to convert only the total to the final unit, and not each product weight.
* However, we might loose precision, not sure about that.
* Based on formulas found at http://jumk.de/calc/gewicht.shtml
* @param array
* @param string
* @return mixed
*/
public function amountIn($strUnit)
{
if (empty($this->arrWeights)) {
return 0;
}
$fltWeight = 0;
foreach ($this->arrWeights as $objWeight) {
if ($objWeight->getWeightValue() > 0) {
$fltWeight += Unit::convert(floatval($objWeight->getWeightValue()), $objWeight->getWeightUnit(), Unit::KILOGRAM);
}
}
return Unit::convert($fltWeight, Unit::KILOGRAM, $strUnit);
}
示例3: toRoman
/**
* @todo Finalize implementation of this method.
*/
protected function toRoman($number)
{
$u = new Unit();
if ($number % $this->numberUnit == 0 && $number < 10000) {
return $this->thousand[$number / $this->numberUnit - 1];
} else {
if ($number < 10000) {
return $this->thousand[$number / $this->numberUnit - 1] . $u->convert($number % $this->numberUnit);
} else {
return 'Fail';
}
}
}
示例4: Unit
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'ConverterRomanNumerals.class.php';
require_once 'Unit.class.php';
require_once 'Dozen.class.php';
require_once 'Hundred.class.php';
require_once 'Thousand.class.php';
$u = new Unit();
echo '0 - ' . $u->convert(0) . '<br />';
echo '1 - ' . $u->convert(1) . '<br />';
echo '2 - ' . $u->convert(2) . '<br />';
echo '3 - ' . $u->convert(3) . '<br />';
echo '5 - ' . $u->convert(5) . '<br />';
echo '7 - ' . $u->convert(7) . '<br />';
echo '9 - ' . $u->convert(9) . '<br />';
echo '10 - ' . $u->convert(10) . '<br />';
echo '20 - ' . $u->convert(20) . '<br />';
echo '24 - ' . $u->convert(24) . '<br />';
echo '26 - ' . $u->convert(26) . '<br />';
echo '40 - ' . $u->convert(40) . '<br />';
echo '50 - ' . $u->convert(50) . '<br />';
echo '70 - ' . $u->convert(70) . '<br />';
echo '90 - ' . $u->convert(90) . '<br />';
echo '92 - ' . $u->convert(92) . '<br />';
echo '94 - ' . $u->convert(94) . '<br />';
echo '95 - ' . $u->convert(95) . '<br />';
echo '99 - ' . $u->convert(99) . '<br />';
echo '101 - ' . $u->convert(101) . '<br />';
echo '111 - ' . $u->convert(111) . '<br />';