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


PHP max函数代码示例

本文整理汇总了PHP中max函数的典型用法代码示例。如果您正苦于以下问题:PHP max函数的具体用法?PHP max怎么用?PHP max使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: onls

 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }
开发者ID:tang86,项目名称:discuz-utf8,代码行数:28,代码来源:log.php

示例2: getAvatar

 public function getAvatar($string, $widthHeight = 12, $theme = 'default')
 {
     $widthHeight = max($widthHeight, 12);
     $md5 = md5($string);
     $fileName = _TMP_DIR_ . '/' . $md5 . '.png';
     if ($this->tmpFileExists($fileName)) {
         return $fileName;
     }
     // Create seed.
     $seed = intval(substr($md5, 0, 6), 16);
     mt_srand($seed);
     $body = array('legs' => mt_rand(0, count($this->availableParts[$theme]['legs']) - 1), 'hair' => mt_rand(0, count($this->availableParts[$theme]['hair']) - 1), 'arms' => mt_rand(0, count($this->availableParts[$theme]['arms']) - 1), 'body' => mt_rand(0, count($this->availableParts[$theme]['body']) - 1), 'eyes' => mt_rand(0, count($this->availableParts[$theme]['eyes']) - 1), 'mouth' => mt_rand(0, count($this->availableParts[$theme]['mouth']) - 1));
     // Avatar random parts.
     $parts = array('legs' => $this->availableParts[$theme]['legs'][$body['legs']], 'hair' => $this->availableParts[$theme]['hair'][$body['hair']], 'arms' => $this->availableParts[$theme]['arms'][$body['arms']], 'body' => $this->availableParts[$theme]['body'][$body['body']], 'eyes' => $this->availableParts[$theme]['eyes'][$body['eyes']], 'mouth' => $this->availableParts[$theme]['mouth'][$body['mouth']]);
     $avatar = imagecreate($widthHeight, $widthHeight);
     imagesavealpha($avatar, true);
     imagealphablending($avatar, false);
     $background = imagecolorallocate($avatar, 0, 0, 0);
     $line_colour = imagecolorallocate($avatar, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55, mt_rand(0, 200) + 55);
     imagecolortransparent($avatar, $background);
     imagefilledrectangle($avatar, 0, 0, $widthHeight, $widthHeight, $background);
     // Fill avatar with random parts.
     foreach ($parts as &$part) {
         $this->drawPart($part, $avatar, $widthHeight, $line_colour, $background);
     }
     imagepng($avatar, $fileName);
     imagecolordeallocate($avatar, $line_colour);
     imagecolordeallocate($avatar, $background);
     imagedestroy($avatar);
     return $fileName;
 }
开发者ID:recallfx,项目名称:monsterid.php,代码行数:31,代码来源:MonsterId.php

示例3: transfer

 /**
  * {@inheritdoc}
  */
 protected function transfer()
 {
     while (!$this->stopped && !$this->source->isConsumed()) {
         if ($this->source->getContentLength() && $this->source->isSeekable()) {
             // If the stream is seekable and the Content-Length known, then stream from the data source
             $body = new ReadLimitEntityBody($this->source, $this->partSize, $this->source->ftell());
         } else {
             // We need to read the data source into a temporary buffer before streaming
             $body = EntityBody::factory();
             while ($body->getContentLength() < $this->partSize && $body->write($this->source->read(max(1, min(10 * Size::KB, $this->partSize - $body->getContentLength()))))) {
             }
         }
         // @codeCoverageIgnoreStart
         if ($body->getContentLength() == 0) {
             break;
         }
         // @codeCoverageIgnoreEnd
         $params = $this->state->getUploadId()->toParams();
         $command = $this->client->getCommand('UploadPart', array_replace($params, array('PartNumber' => count($this->state) + 1, 'Body' => $body, 'ContentMD5' => (bool) $this->options['part_md5'], Ua::OPTION => Ua::MULTIPART_UPLOAD)));
         // Notify observers that the part is about to be uploaded
         $eventData = $this->getEventData();
         $eventData['command'] = $command;
         $this->dispatch(self::BEFORE_PART_UPLOAD, $eventData);
         // Allow listeners to stop the transfer if needed
         if ($this->stopped) {
             break;
         }
         $response = $command->getResponse();
         $this->state->addPart(UploadPart::fromArray(array('PartNumber' => count($this->state) + 1, 'ETag' => $response->getHeader('ETag', true), 'Size' => $body->getContentLength(), 'LastModified' => gmdate(DateFormat::RFC2822))));
         // Notify observers that the part was uploaded
         $this->dispatch(self::AFTER_PART_UPLOAD, $eventData);
     }
 }
开发者ID:romainneutron,项目名称:aws-sdk-php,代码行数:36,代码来源:SerialTransfer.php

示例4: humanReadableBytes

 /**
  * Get human readable file size, quick and dirty.
  * 
  * @todo Improve i18n support.
  *
  * @param int $bytes
  * @param string $format
  * @param int|null $decimal_places
  * @return string Human readable string with file size.
  */
 public static function humanReadableBytes($bytes, $format = "en", $decimal_places = null)
 {
     switch ($format) {
         case "sv":
             $dec_separator = ",";
             $thousands_separator = " ";
             break;
         default:
         case "en":
             $dec_separator = ".";
             $thousands_separator = ",";
             break;
     }
     $b = (int) $bytes;
     $s = array('B', 'kB', 'MB', 'GB', 'TB');
     if ($b <= 0) {
         return "0 " . $s[0];
     }
     $con = 1024;
     $e = (int) log($b, $con);
     $e = min($e, count($s) - 1);
     $v = $b / pow($con, $e);
     if ($decimal_places === null) {
         $decimal_places = max(0, 2 - (int) log($v, 10));
     }
     return number_format($v, !$e ? 0 : $decimal_places, $dec_separator, $thousands_separator) . ' ' . $s[$e];
 }
开发者ID:varvanin,项目名称:currycms,代码行数:37,代码来源:Util.php

示例5: GenerateLogo

	public function GenerateLogo()
	{
		$this->NewLogo($this->FileType); // defaults to png. can use jpg or gif as well

		$this->FontPath = dirname(__FILE__) . '/fonts/';
		$this->ImagePath = dirname(__FILE__) . '/';
		$this->SetBackgroundImage('back.png');
		$size = getimagesize(dirname(__FILE__)."/back.png");
		$imageHeight = $size['1'];

		if(strlen($this->Text[0]) > 0) {
			// AddText() - text, font, fontcolor, fontSize (pt), x, y, center on this width
			$text_position = $this->AddText($this->Text[0], 'xt.otf', 'd0a642', 15, 43, 20);
			$top_right = $text_position['top_right_x'];
		}
		else {
			$top_right = 0;
		}

		if(strlen($this->Text[1]) > 0) {
			// put in our second bit of text
			$text_position2 = $this->AddText($this->Text[1], 'xt.otf', 'ffffff', 45, 5, 46);
			$top_right = max($top_right, $text_position2['top_right_x']);
		}

		if(strlen($this->Text[2]) > 0) {
			// put in our third bit of text
			$text_position3 = $this->AddText($this->Text[2], 'xt.otf', 'b49a5d', 20, 75, 100);
			$top_right = max($top_right, $text_position3['top_right_x']);
		}
		$this->SetImageSize($top_right+20, $imageHeight);
		$this->CropImage = true;

		return $this->MakeLogo();
	}
开发者ID:hungnv0789,项目名称:vhtm,代码行数:35,代码来源:config.php

示例6: getSize

 function getSize($TextString, $Format = "")
 {
     $Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
     $ShowLegend = isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
     $LegendOffset = isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
     $DrawArea = isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
     $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : 12;
     $Height = isset($Format["Height"]) ? $Format["Height"] : 30;
     $TextString = $this->encode39($TextString);
     $BarcodeLength = strlen($this->Result);
     if ($DrawArea) {
         $WOffset = 20;
     } else {
         $WOffset = 0;
     }
     if ($ShowLegend) {
         $HOffset = $FontSize + $LegendOffset + $WOffset;
     } else {
         $HOffset = 0;
     }
     $X1 = cos($Angle * PI / 180) * ($WOffset + $BarcodeLength);
     $Y1 = sin($Angle * PI / 180) * ($WOffset + $BarcodeLength);
     $X2 = $X1 + cos(($Angle + 90) * PI / 180) * ($HOffset + $Height);
     $Y2 = $Y1 + sin(($Angle + 90) * PI / 180) * ($HOffset + $Height);
     $AreaWidth = max(abs($X1), abs($X2));
     $AreaHeight = max(abs($Y1), abs($Y2));
     return array("Width" => $AreaWidth, "Height" => $AreaHeight);
 }
开发者ID:ambagasdowa,项目名称:projections,代码行数:28,代码来源:pBarcode39.class.php

示例7: splitPageResults

 function splitPageResults(&$current_page_number, $max_rows_per_page, &$sql_query, &$query_num_rows)
 {
     if (empty($current_page_number)) {
         $current_page_number = 1;
     }
     $pos_to = strlen($sql_query);
     $pos_from = strpos($sql_query, ' from', 0);
     $pos_group_by = strpos($sql_query, ' group by', $pos_from);
     if ($pos_group_by < $pos_to && $pos_group_by != false) {
         $pos_to = $pos_group_by;
     }
     $pos_having = strpos($sql_query, ' having', $pos_from);
     if ($pos_having < $pos_to && $pos_having != false) {
         $pos_to = $pos_having;
     }
     $pos_order_by = strpos($sql_query, ' order by', $pos_from);
     if ($pos_order_by < $pos_to && $pos_order_by != false) {
         $pos_to = $pos_order_by;
     }
     $reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, $pos_to - $pos_from));
     $reviews_count = tep_db_fetch_array($reviews_count_query);
     $query_num_rows = $reviews_count['total'];
     $num_pages = ceil($query_num_rows / $max_rows_per_page);
     if ($current_page_number > $num_pages) {
         $current_page_number = $num_pages;
     }
     $offset = $max_rows_per_page * ($current_page_number - 1);
     $sql_query .= " limit " . max($offset, 0) . ", " . $max_rows_per_page;
 }
开发者ID:tiansiyuan,项目名称:oscommerce2,代码行数:29,代码来源:split_page_results.php

示例8: phutil_format_relative_time_detailed

/**
 * Format a relative time (duration) into weeks, days, hours, minutes,
 * seconds, but unlike phabricator_format_relative_time, does so for more than
 * just the largest unit.
 *
 * @param int Duration in seconds.
 * @param int Levels to render - will render the three highest levels, ie:
 *            5 h, 37 m, 1 s
 * @return string Human-readable description.
 */
function phutil_format_relative_time_detailed($duration, $levels = 2)
{
    if ($duration == 0) {
        return 'now';
    }
    $levels = max(1, min($levels, 5));
    $remainder = 0;
    $is_negative = false;
    if ($duration < 0) {
        $is_negative = true;
        $duration = abs($duration);
    }
    $this_level = 1;
    $detailed_relative_time = phutil_format_units_generic($duration, array(60, 60, 24, 7), array('s', 'm', 'h', 'd', 'w'), $precision = 0, $remainder);
    $duration = $remainder;
    while ($remainder > 0 && $this_level < $levels) {
        $detailed_relative_time .= ', ' . phutil_format_units_generic($duration, array(60, 60, 24, 7), array('s', 'm', 'h', 'd', 'w'), $precision = 0, $remainder);
        $duration = $remainder;
        $this_level++;
    }
    if ($is_negative) {
        $detailed_relative_time .= ' ago';
    }
    return $detailed_relative_time;
}
开发者ID:barcelonascience,项目名称:libphutil,代码行数:35,代码来源:viewutils.php

示例9: save

 public function save()
 {
     $maxHeight = 0;
     $width = 0;
     foreach ($this->_segmentsArray as $segment) {
         $maxHeight = max($maxHeight, $segment->height);
         $width += $segment->width;
     }
     // create our canvas
     $img = imagecreatetruecolor($width, $maxHeight);
     $background = imagecolorallocatealpha($img, 255, 255, 255, 127);
     imagefill($img, 0, 0, $background);
     imagealphablending($img, false);
     imagesavealpha($img, true);
     // start placing our images on a single x axis
     $xPos = 0;
     foreach ($this->_segmentsArray as $segment) {
         $tmp = imagecreatefromjpeg($segment->pathToImage);
         imagecopy($img, $tmp, $xPos, 0, 0, 0, $segment->width, $segment->height);
         $xPos += $segment->width;
         imagedestroy($tmp);
     }
     // create our final output image.
     imagepng($img, $this->_saveToPath);
 }
开发者ID:ejacobs,项目名称:css-sprite,代码行数:25,代码来源:CssSprite.php

示例10: Row

 function Row($data)
 {
     //Calculate the height of the row
     $h = 0;
     $numData = count($data);
     for ($i = 0; $i < $numData; $i++) {
         $hTmp = $this->getStringHeight($this->widths[$i], $data[$i]);
         $h = max($h, $hTmp);
     }
     $h += 0.5;
     //Issue a page break first if needed
     $this->CheckPageBreak($h);
     //Draw the cells of the row
     for ($i = 0; $i < $numData; $i++) {
         $w = $this->widths[$i];
         $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
         //Save the current position
         $x = $this->GetX();
         $y = $this->GetY();
         //Draw the border
         $this->Rect($x, $y, $w, $h);
         //Print the text
         $this->MultiCell($w, $h, $data[$i], 0, $a);
         //Put the position to the right of the cell
         $this->SetXY($x + $w, $y);
     }
     //Go to the next line
     $this->Ln($h);
 }
开发者ID:sukma279,项目名称:GIS,代码行数:29,代码来源:mc_table.php

示例11: convert

 public function convert()
 {
     $paddingTop = array_key_exists('SpaceBefore', $this->idmlContext) ? $this->idmlContext['SpaceBefore'] : '0';
     $paddingRight = array_key_exists('RightIndent', $this->idmlContext) ? $this->idmlContext['RightIndent'] : '0';
     $paddingBottom = array_key_exists('SpaceAfter', $this->idmlContext) ? $this->idmlContext['SpaceAfter'] : '0';
     $paddingLeft = array_key_exists('LeftIndent', $this->idmlContext) ? $this->idmlContext['LeftIndent'] : '0';
     // InDesign allows negative SpaceBefore and SpaceAfter, but CSS does not allow negative padding.
     $paddingTop = max(0, $paddingTop);
     $paddingBottom = max(0, $paddingBottom);
     $paddingTop = round($paddingTop);
     $paddingRight = round($paddingRight);
     $paddingBottom = round($paddingBottom);
     $paddingLeft = round($paddingLeft);
     if ($paddingTop == $paddingRight && $paddingRight == $paddingBottom && $paddingBottom == $paddingLeft) {
         $this->registerCSS('padding', $paddingTop . 'px');
     } else {
         $this->registerCSS('padding', sprintf("%dpx %dpx %dpx %dpx", $paddingTop, $paddingRight, $paddingBottom, $paddingLeft));
     }
     // IDML differs from CSS in it's implementation of space before the first paragraph.
     // IDML only uses SpaceBefore for the second and subsequent paragraphs, so we need CSS
     // to suppress padding-top on the first paragraph.
     if ($paddingTop > 0 && $this->decodeContext == 'Typography') {
         $this->registerPseudoCSS('first-of-type', 'padding', sprintf("%dpx %dpx %dpx %dpx", 0, $paddingRight, $paddingBottom, $paddingLeft));
     }
 }
开发者ID:skypeter1,项目名称:webapps,代码行数:25,代码来源:IdmlDecodeParagraphPadding.php

示例12: Row

 function Row($data)
 {
     //Calculate the height of the row
     $nb = 0;
     for ($i = 0; $i < count($data); $i++) {
         $nb = max($nb, $this->NbLines($this->widths[$i], $data[$i]));
     }
     $h = 5 * $nb;
     //Issue a page break first if needed
     $this->CheckPageBreak($h);
     //Draw the cells of the row
     for ($i = 0; $i < count($data); $i++) {
         $w = $this->widths[$i];
         $a = isset($this->aligns[$i]) ? $this->aligns[$i] : 'L';
         //Save the current position
         $x = $this->GetX();
         $y = $this->GetY();
         //Draw the border
         $this->Rect($x, $y, $w, $h);
         //Print the text
         if (count($data) - 1 == $i && strtolower($data[count($data) - 1]) == 'desactivado') {
             $this->SetTextColor(255, 0, 0);
         } else {
             $this->SetTextColor(0, 0, 0);
         }
         $this->MultiCell($w, 5, $data[$i], 0, $a);
         //Put the position to the right of the cell
         $this->SetXY($x + $w, $y);
     }
     //Go to the next line
     $this->Ln($h);
 }
开发者ID:RJPC,项目名称:dirhac,代码行数:32,代码来源:pdf_tema.php

示例13: execute

 public function execute()
 {
     if ($target_blog = max(0, $this->getRequest()->post('blog', 0, waRequest::TYPE_INT))) {
         $blog_model = new blogBlogModel();
         if ($blog = $blog_model->getById($target_blog)) {
             if ($ids = $this->getRequest()->post('id', null, waRequest::TYPE_ARRAY_INT)) {
                 $post_model = new blogPostModel();
                 $comment_model = new blogCommentModel();
                 $this->response['moved'] = array();
                 foreach ($ids as $id) {
                     try {
                         //rights will checked for each record separately
                         $post_model->updateItem($id, array('blog_id' => $target_blog));
                         $comment_model->updateByField('post_id', $id, array('blog_id' => $target_blog));
                         $this->response['moved'][$id] = $id;
                     } catch (Exception $ex) {
                         if (!isset($this->response['error'])) {
                             $this->response['error'] = array();
                         }
                         $this->response['error'][$id] = $ex->getMessage();
                     }
                 }
                 $this->response['style'] = $blog['color'];
                 $blog_model->recalculate();
             }
         } else {
         }
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:29,代码来源:blogPostMove.controller.php

示例14: main

 public function main($UrlAppend = NULL, $get = NULL, $post = NULL)
 {
     if (!$_REQUEST['server_id']) {
         return array();
     }
     $this->_assign['URL_silenceLocalLog'] = $this->_urlLocalLog();
     $this->_assign['URL_silenceInGame'] = $this->_urlInGame();
     switch ($_REQUEST['doaction']) {
         case self::INGAME:
             //拿游戏中实际封号数据
             $this->_dataInLocalLog();
             break;
         default:
             $getData = $this->_gameObject->getGetData($get);
             $getData["Page"] = max(0, intval($_GET['page']));
             $data = $this->getResult($UrlAppend, $getData);
             //		print_r($data);
             if ($data['states'] == '1') {
                 $this->_assign['dataList'] = $data["List"];
                 $this->_loadCore('Help_Page');
                 $helpPage = new Help_Page(array('total' => $data["Count"], 'perpage' => PAGE_SIZE));
                 $this->_assign['pageBox'] = $helpPage->show();
             }
             $this->_assign['gameData'] = 1;
             break;
     }
     $this->_assign['Add_Url'] = $this->_urlAdd();
     $this->_assign['Del_Url'] = $this->_urlDel();
     return $this->_assign;
 }
开发者ID:huangwei2wei,项目名称:kfxt,代码行数:30,代码来源:Default_1.class.php

示例15: rebuild

 /**
  * @param int $position
  * @param array $options
  * @param string $detailedMessage
  * @return bool|int|string|true
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     /* @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     $locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
     if (count($locations) < 1) {
         return true;
     }
     XenForo_Db::beginTransaction();
     $db = XenForo_Application::getDb();
     /** @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     foreach ($locations as $locationId => $location) {
         $position = $location['location_id'];
         try {
             $client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
             $response = $client->request('GET');
             $response = @json_decode($response->getBody(), true);
             if (empty($response['results'][0])) {
                 continue;
             }
             $address = $response['results'][0]['formatted_address'];
             $lat = $response['results'][0]['geometry']['location']['lat'];
             $lng = $response['results'][0]['geometry']['location']['lng'];
             $db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
         } catch (Exception $e) {
             continue;
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:40,代码来源:Location.php


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