當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Unit::convert方法代碼示例

本文整理匯總了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);
     }
 }
開發者ID:YurePereira,項目名稱:fypa-design-patterns,代碼行數:9,代碼來源:Hundred.class.php

示例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);
 }
開發者ID:codefog,項目名稱:contao-haste,代碼行數:23,代碼來源:Scale.php

示例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';
         }
     }
 }
開發者ID:YurePereira,項目名稱:fypa-design-patterns,代碼行數:16,代碼來源:Thousand.class.php

示例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 />';
開發者ID:YurePereira,項目名稱:fypa-design-patterns,代碼行數:31,代碼來源:test.php


注:本文中的Unit::convert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。