当前位置: 首页>>代码示例>>PHP>>正文


PHP Math::ceil方法代码示例

本文整理汇总了PHP中Math::ceil方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::ceil方法的具体用法?PHP Math::ceil怎么用?PHP Math::ceil使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Math的用法示例。


在下文中一共展示了Math::ceil方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: hex

 static function hex($n, $digits = null)
 {
     $s = dechex($n);
     $len = 8;
     if (strlen($s) > StringTools_0($digits, $len, $n, $s)) {
         $s = _hx_substr($s, -$len, null);
     } else {
         if ($digits !== null) {
             if (strlen("0") === 0 || strlen($s) >= $digits) {
                 $s = $s;
             } else {
                 $s = str_pad($s, Math::ceil(($digits - strlen($s)) / strlen("0")) * strlen("0") + strlen($s), "0", STR_PAD_LEFT);
             }
         }
     }
     return strtoupper($s);
 }
开发者ID:marcdraco,项目名称:Webrathea,代码行数:17,代码来源:StringTools.class.php

示例2: strftime

 static function strftime($dti, $format)
 {
     if (!php_Boot::$skip_constructor) {
         $prevPos = 0;
         $pos = _hx_index_of($format, "%", null);
         $str = "";
         while ($pos >= 0) {
             $str .= _hx_string_or_null(_hx_substring($format, $prevPos, $pos));
             $pos++;
             $_g = ord(substr($format, $pos, 1));
             switch ($_g) {
                 case 89:
                     $s = _hx_string_rec($dti->getYears(), "") . "";
                     if (strlen("0") === 0 || strlen($s) >= 2) {
                         $str .= _hx_string_or_null($s);
                     } else {
                         $str .= _hx_string_or_null(str_pad($s, Math::ceil((2 - strlen($s)) / strlen("0")) * strlen("0") + strlen($s), "0", STR_PAD_LEFT));
                     }
                     break;
                 case 121:
                     $str .= _hx_string_rec($dti->getYears(), "") . "";
                     break;
                 case 77:
                     $s1 = _hx_string_rec($dti->getMonths(), "") . "";
                     if (strlen("0") === 0 || strlen($s1) >= 2) {
                         $str .= _hx_string_or_null($s1);
                     } else {
                         $str .= _hx_string_or_null(str_pad($s1, Math::ceil((2 - strlen($s1)) / strlen("0")) * strlen("0") + strlen($s1), "0", STR_PAD_LEFT));
                     }
                     break;
                 case 109:
                     $str .= _hx_string_rec($dti->getMonths(), "") . "";
                     break;
                 case 98:
                     $str .= _hx_string_rec($dti->getTotalMonths(), "") . "";
                     break;
                 case 68:
                     $s2 = _hx_string_rec($dti->getDays(), "") . "";
                     if (strlen("0") === 0 || strlen($s2) >= 2) {
                         $str .= _hx_string_or_null($s2);
                     } else {
                         $str .= _hx_string_or_null(str_pad($s2, Math::ceil((2 - strlen($s2)) / strlen("0")) * strlen("0") + strlen($s2), "0", STR_PAD_LEFT));
                     }
                     break;
                 case 100:
                     $str .= _hx_string_rec($dti->getDays(), "") . "";
                     break;
                 case 97:
                     $str .= _hx_string_rec($dti->getTotalDays(), "") . "";
                     break;
                 case 72:
                     $s3 = _hx_string_rec($dti->getHours(), "") . "";
                     if (strlen("0") === 0 || strlen($s3) >= 2) {
                         $str .= _hx_string_or_null($s3);
                     } else {
                         $str .= _hx_string_or_null(str_pad($s3, Math::ceil((2 - strlen($s3)) / strlen("0")) * strlen("0") + strlen($s3), "0", STR_PAD_LEFT));
                     }
                     break;
                 case 104:
                     $str .= _hx_string_rec($dti->getHours(), "") . "";
                     break;
                 case 99:
                     $str .= _hx_string_rec($dti->getTotalHours(), "") . "";
                     break;
                 case 73:
                     $s4 = _hx_string_rec($dti->getMinutes(), "") . "";
                     if (strlen("0") === 0 || strlen($s4) >= 2) {
                         $str .= _hx_string_or_null($s4);
                     } else {
                         $str .= _hx_string_or_null(str_pad($s4, Math::ceil((2 - strlen($s4)) / strlen("0")) * strlen("0") + strlen($s4), "0", STR_PAD_LEFT));
                     }
                     break;
                 case 105:
                     $str .= _hx_string_rec($dti->getMinutes(), "") . "";
                     break;
                 case 101:
                     $str .= _hx_string_rec($dti->getTotalMinutes(), "") . "";
                     break;
                 case 83:
                     $s5 = _hx_string_rec($dti->getSeconds(), "") . "";
                     if (strlen("0") === 0 || strlen($s5) >= 2) {
                         $str .= _hx_string_or_null($s5);
                     } else {
                         $str .= _hx_string_or_null(str_pad($s5, Math::ceil((2 - strlen($s5)) / strlen("0")) * strlen("0") + strlen($s5), "0", STR_PAD_LEFT));
                     }
                     break;
                 case 115:
                     $str .= _hx_string_rec($dti->getSeconds(), "") . "";
                     break;
                 case 102:
                     $str .= _hx_string_rec($dti->getTotalSeconds(), "") . "";
                     break;
                 case 82:
                     if ($dti->negative) {
                         $str .= "-";
                     } else {
                         $str .= "+";
                     }
                     break;
                 case 114:
//.........这里部分代码省略.........
开发者ID:ypid,项目名称:suncalc-php,代码行数:101,代码来源:DateTimeIntervalUtils.class.php

示例3: fieldsString

 public function fieldsString($v, $fields)
 {
     $this->buf->b .= "{";
     $len = $fields->length;
     $last = $len - 1;
     $first = true;
     $_g = 0;
     while ($_g < $len) {
         $i = $_g++;
         $f = $fields[$i];
         $value = Reflect::field($v, $f);
         if (Reflect::isFunction($value)) {
             continue;
         }
         if ($first) {
             $this->nind++;
             $first = false;
         } else {
             $this->buf->b .= ",";
         }
         if ($this->pretty) {
             $this->buf->b .= "\n";
         }
         if ($this->pretty) {
             $v1 = null;
             $c = $this->indent;
             $l = $this->nind * strlen($this->indent);
             if (strlen($c) === 0 || strlen("") >= $l) {
                 $v1 = "";
             } else {
                 $v1 = str_pad("", Math::ceil(($l - strlen("")) / strlen($c)) * strlen($c) + strlen(""), $c, STR_PAD_LEFT);
             }
             unset($l, $c);
             $this->buf->add($v1);
             unset($v1);
         }
         $this->quote($f);
         $this->buf->b .= ":";
         if ($this->pretty) {
             $this->buf->b .= " ";
         }
         $this->write($f, $value);
         if ($i === $last) {
             $this->nind--;
             if ($this->pretty) {
                 $this->buf->b .= "\n";
             }
             if ($this->pretty) {
                 $v2 = null;
                 $c1 = $this->indent;
                 $l1 = $this->nind * strlen($this->indent);
                 if (strlen($c1) === 0 || strlen("") >= $l1) {
                     $v2 = "";
                 } else {
                     $v2 = str_pad("", Math::ceil(($l1 - strlen("")) / strlen($c1)) * strlen($c1) + strlen(""), $c1, STR_PAD_LEFT);
                 }
                 unset($l1, $c1);
                 $this->buf->add($v2);
                 unset($v2);
             }
         }
         unset($value, $i, $f);
     }
     $this->buf->b .= "}";
 }
开发者ID:sp-ruben-simon,项目名称:daff-php,代码行数:65,代码来源:JsonPrinter.class.php

示例4: strftime

 static function strftime($dt, $format)
 {
     $prevPos = 0;
     $pos = _hx_index_of($format, "%", null);
     $str = "";
     while ($pos >= 0) {
         $str .= _hx_string_or_null(_hx_substring($format, $prevPos, $pos));
         $pos++;
         $_g = ord(substr($format, $pos, 1));
         switch ($_g) {
             case 100:
                 $s = null;
                 $s = _hx_string_rec(datetime_utils_DateTimeUtils_5($_g, $dt, $format, $pos, $prevPos, $s, $str), "") . "";
                 if (strlen("0") === 0 || strlen($s) >= 2) {
                     $str .= _hx_string_or_null($s);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s, Math::ceil((2 - strlen($s)) / strlen("0")) * strlen("0") + strlen($s), "0", STR_PAD_LEFT));
                 }
                 break;
             case 101:
                 $s1 = null;
                 $s1 = _hx_string_rec(datetime_utils_DateTimeUtils_6($_g, $dt, $format, $pos, $prevPos, $s1, $str), "") . "";
                 if (strlen(" ") === 0 || strlen($s1) >= 2) {
                     $str .= _hx_string_or_null($s1);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s1, Math::ceil((2 - strlen($s1)) / strlen(" ")) * strlen(" ") + strlen($s1), " ", STR_PAD_LEFT));
                 }
                 break;
             case 106:
                 $day = Std::int(($dt - 62135596800.0 - datetime__DateTime_DateTime_Impl_::yearStart($dt)) / 86400) + 1;
                 $s2 = "" . _hx_string_rec($day, "");
                 if (strlen("0") === 0 || strlen($s2) >= 3) {
                     $str .= _hx_string_or_null($s2);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s2, Math::ceil((3 - strlen($s2)) / strlen("0")) * strlen("0") + strlen($s2), "0", STR_PAD_LEFT));
                 }
                 break;
             case 117:
                 $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getWeekDay($dt, true), "") . "";
                 break;
             case 119:
                 $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getWeekDay($dt, null), "") . "";
                 break;
             case 109:
                 $s3 = null;
                 $s3 = _hx_string_rec(datetime_utils_DateTimeUtils_7($_g, $dt, $format, $pos, $prevPos, $s3, $str), "") . "";
                 if (strlen("0") === 0 || strlen($s3) >= 2) {
                     $str .= _hx_string_or_null($s3);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s3, Math::ceil((2 - strlen($s3)) / strlen("0")) * strlen("0") + strlen($s3), "0", STR_PAD_LEFT));
                 }
                 break;
             case 67:
                 $s4 = _hx_string_rec(Std::int(datetime__DateTime_DateTime_Impl_::getYear($dt) / 100), "") . "";
                 if (strlen("0") === 0 || strlen($s4) >= 2) {
                     $str .= _hx_string_or_null($s4);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s4, Math::ceil((2 - strlen($s4)) / strlen("0")) * strlen("0") + strlen($s4), "0", STR_PAD_LEFT));
                 }
                 break;
             case 121:
                 $s5 = _hx_substr(_hx_string_rec(datetime__DateTime_DateTime_Impl_::getYear($dt), "") . "", -2, null);
                 if (strlen("0") === 0 || strlen($s5) >= 2) {
                     $str .= _hx_string_or_null($s5);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s5, Math::ceil((2 - strlen($s5)) / strlen("0")) * strlen("0") + strlen($s5), "0", STR_PAD_LEFT));
                 }
                 break;
             case 89:
                 $str .= _hx_string_rec(datetime__DateTime_DateTime_Impl_::getYear($dt), "") . "";
                 break;
             case 86:
                 $s6 = _hx_string_rec(datetime__DateTime_DateTime_Impl_::getWeek($dt), "") . "";
                 if (strlen("0") === 0 || strlen($s6) >= 2) {
                     $str .= _hx_string_or_null($s6);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s6, Math::ceil((2 - strlen($s6)) / strlen("0")) * strlen("0") + strlen($s6), "0", STR_PAD_LEFT));
                 }
                 break;
             case 72:
                 $s7 = _hx_string_rec(Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600), "") . "";
                 if (strlen("0") === 0 || strlen($s7) >= 2) {
                     $str .= _hx_string_or_null($s7);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s7, Math::ceil((2 - strlen($s7)) / strlen("0")) * strlen("0") + strlen($s7), "0", STR_PAD_LEFT));
                 }
                 break;
             case 107:
                 $s8 = _hx_string_rec(Std::int(($dt - Math::ffloor($dt / 86400) * 86400) / 3600), "") . "";
                 if (strlen(" ") === 0 || strlen($s8) >= 2) {
                     $str .= _hx_string_or_null($s8);
                 } else {
                     $str .= _hx_string_or_null(str_pad($s8, Math::ceil((2 - strlen($s8)) / strlen(" ")) * strlen(" ") + strlen($s8), " ", STR_PAD_LEFT));
                 }
                 break;
             case 73:
                 $s9 = _hx_string_rec(datetime__DateTime_DateTime_Impl_::getHour12($dt), "") . "";
                 if (strlen("0") === 0 || strlen($s9) >= 2) {
                     $str .= _hx_string_or_null($s9);
                 } else {
//.........这里部分代码省略.........
开发者ID:ypid,项目名称:suncalc-php,代码行数:101,代码来源:DateTimeUtils.class.php


注:本文中的Math::ceil方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。