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


PHP round函数代码示例

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


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

示例1: composeDetails

 /**
  * {@inheritdoc}
  */
 protected function composeDetails(PaymentInterface $payment, TokenInterface $token)
 {
     if ($payment->getDetails()) {
         return;
     }
     $order = $payment->getOrder();
     $details = array();
     $details['payment_method'] = $this->apiMethod($payment->getMethod()->getName());
     $details['payment_type'] = 1;
     $details['checkout_url'] = $this->tokenFactory->createNotifyToken($token->getPaymentName(), $payment)->getTargetUrl();
     $details['order_code'] = $order->getNumber() . '-' . $payment->getId();
     $details['cur_code'] = $order->getCurrency();
     $details['total_amount'] = round($order->getTotal() / 100, 2);
     $details['total_item'] = count($order->getItems());
     $m = 0;
     foreach ($order->getItems() as $item) {
         $details['item_name' . $m] = $item->getId();
         $details['item_amount' . $m] = round($item->getTotal() / $item->getQuantity() / 100, 2);
         $details['item_quantity' . $m] = $item->getQuantity();
         $m++;
     }
     if (0 !== ($taxTotal = $this->calculateNonNeutralTaxTotal($order))) {
         $details['tax_amount'] = $taxTotal;
     }
     if (0 !== ($promotionTotal = $order->getAdjustmentsTotal(AdjustmentInterface::PROMOTION_ADJUSTMENT))) {
         $details['discount_amount'] = $promotionTotal;
     }
     if (0 !== ($shippingTotal = $order->getAdjustmentsTotal(AdjustmentInterface::SHIPPING_ADJUSTMENT))) {
         $details['fee_shipping'] = $shippingTotal;
     }
     $payment->setDetails($details);
 }
开发者ID:ekipower,项目名称:payum-nganluong,代码行数:35,代码来源:CapturePaymentUsingXXXAction.php

示例2: calculateGFRResult

 function calculateGFRResult()
 {
     $tmpArr = array();
     $tmpArr[] = date('Y-m-d H:i:s');
     //observation time
     $tmpArr[] = 'GFR (CALC)';
     //desc
     $gender = NSDR::populate($this->_patientId . "::com.clearhealth.person.displayGender");
     $crea = NSDR::populate($this->_patientId . "::com.clearhealth.labResults[populate(@description=CREA)]");
     $genderFactor = null;
     $creaValue = null;
     $personAge = null;
     $raceFactor = 1;
     switch ($gender[key($gender)]) {
         case 'M':
             $genderFactor = 1;
             break;
         case 'F':
             $genderFactor = 0.742;
             break;
     }
     if ((int) strtotime($crea['observation_time']) >= strtotime('now - 60 days') && strtolower($crea[key($crea)]['units']) == 'mg/dl') {
         $creaValue = $crea[key($crea)]['value'];
     }
     $person = new Person();
     $person->personId = $this->_patientId;
     $person->populate();
     if ($person->age > 0) {
         $personAge = $person->age;
     }
     $personStat = new PatientStatistics();
     $personStat->personId = $this->_patientId;
     $personStat->populate();
     if ($personStat->race == "AFAM") {
         $raceFactor = 1.21;
     }
     $gfrValue = "INC";
     if ($personAge > 0 && $creaValue > 0) {
         $gfrValue = "" . (int) round(pow($creaValue, -1.154) * pow($personAge, -0.203) * $genderFactor * $raceFactor * 186);
     }
     trigger_error("gfr:: " . $gfrValue, E_USER_NOTICE);
     $tmpArr[] = $gfrValue;
     // lab value
     $tmpArr[] = 'mL/min/1.73 m2';
     //units
     $tmpArr[] = '';
     //ref range
     $tmpArr[] = '';
     //abnormal
     $tmpArr[] = 'F';
     //status
     $tmpArr[] = date('Y-m-d H:i:s') . '::' . '0';
     // observationTime::(boolean)normal; 0 = abnormal, 1 = normal
     $tmpArr[] = '0';
     //sign
     //$this->_calcLabResults[uniqid()] = $tmpArr;
     $this->_calcLabResults[1] = $tmpArr;
     // temporarily set index to one(1) to be able to include in selected lab results
     return $tmpArr;
 }
开发者ID:dragonlet,项目名称:clearhealth,代码行数:60,代码来源:CalcLabs.php

示例3: renderResultList

 protected function renderResultList(array $countdowns, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($countdowns, 'PhabricatorCountdown');
     $viewer = $this->requireViewer();
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($countdowns as $countdown) {
         $id = $countdown->getID();
         $ended = false;
         $epoch = $countdown->getEpoch();
         if ($epoch <= PhabricatorTime::getNow()) {
             $ended = true;
         }
         $item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($countdown)->setObjectName("C{$id}")->setHeader($countdown->getTitle())->setHref($this->getApplicationURI("{$id}/"))->addByline(pht('Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink()));
         if ($ended) {
             $item->addAttribute(pht('Launched on %s', phabricator_datetime($epoch, $viewer)));
             $item->setDisabled(true);
         } else {
             $time_left = $epoch - PhabricatorTime::getNow();
             $num = round($time_left / (60 * 60 * 24));
             $noun = pht('Days');
             if ($num < 1) {
                 $num = round($time_left / (60 * 60), 1);
                 $noun = pht('Hours');
             }
             $item->setCountdown($num, $noun);
             $item->addAttribute(phabricator_datetime($epoch, $viewer));
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No countdowns found.'));
     return $result;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:35,代码来源:PhabricatorCountdownSearchEngine.php

示例4: dateDiff

function dateDiff($start, $end)
{
    $start_ts = strtotime($start);
    $end_ts = strtotime($end);
    $diff = $end_ts - $start_ts;
    return round($diff / 86400);
}
开发者ID:bamcod,项目名称:Disease-Surveillance,代码行数:7,代码来源:ReadOnly.php

示例5: query_operon_gene_percentage

function query_operon_gene_percentage($species_id)
{
    $spe = array();
    $spe['name'] = '';
    $spe['ncs'] = array();
    $spe['total_gene'] = 0;
    $spe['in_operon'] = 0;
    $species_id = mysql_real_escape_string($species_id);
    $sql = "SELECT id, name FROM Species WHERE id={$species_id}";
    $result = mysql_query($sql) or die("Invalid query: " . mysql_error());
    $row = mysql_fetch_array($result);
    $spe['name'] = $row['name'];
    unset($result);
    $sql = "SELECT id,NC_id,protein_gene_number,rna_gene_number,operon_number FROM NC WHERE species_id={$species_id}";
    $result = mysql_query($sql) or die("Invalid query: " . mysql_error());
    $n = mysql_num_rows($result);
    for ($i = 0; $i < $n; $i++) {
        $row = mysql_fetch_array($result);
        $NC_id = $row['id'];
        $row['total_gene_num'] = $row['protein_gene_number'] + $row['rna_gene_number'];
        $sql2 = "SELECT sum(size) as total_genes FROM Operon WHERE size>=2 AND NC_id={$NC_id} ORDER BY id";
        $result2 = mysql_query($sql2) or die("Invalid query: " . mysql_error());
        $row2 = mysql_fetch_array($result2);
        $row['gene_in_operon'] = $row2['total_genes'];
        #$row['percent'] = round($row['gene_in_operon'] / $row['total_gene_num'],2);
        array_push($spe['ncs'], $row);
        $spe['total_gene'] += $row['total_gene_num'];
        $spe['in_operon'] += $row['gene_in_operon'];
    }
    $spe['percent'] = round(100 * $spe['in_operon'] / $spe['total_gene'], 2);
    return $spe;
}
开发者ID:jluzhhy,项目名称:Cross-microrna,代码行数:32,代码来源:NC_statistic.php

示例6: getThumbnailDimension

	function getThumbnailDimension($path, $w, $h)
	{
		$dim = array('w' => $w, 'h' => $h);
		if ($w && $h || (!$w && !$h)) return $dim;

		if (@is_readable($path) && function_exists('getimagesize'))
		{
			$info = @getimagesize($path);
			if (!empty($info) && count($info) > 1)
			{
				if (empty($w))
				{
					$w = round($h * $info[0] / $info[1]);
					$dim['w'] = $w;
				}
				else
				{
					$h = round($w * $info[1] / $info[0]);
					$dim['h'] = $h;
				}
			}
		}
		
		return $dim;
	}
开发者ID:xenten,项目名称:swift-kanban,代码行数:25,代码来源:class.ImageHelper.php

示例7: imageDualResize

 function imageDualResize($filename, $cleanFilename, $wtarget, $htarget)
 {
     if (!file_exists($cleanFilename)) {
         $dims = getimagesize($filename);
         $width = $dims[0];
         $height = $dims[1];
         while ($width > $wtarget || $height > $htarget) {
             if ($width > $wtarget) {
                 $percentage = $wtarget / $width;
             }
             if ($height > $htarget) {
                 $percentage = $htarget / $height;
             }
             /*if($width > $height)
             		{
             			$percentage = ($target / $width);
             		}
             		else
             		{
             			$percentage = ($target / $height);
             		}*/
             //gets the new value and applies the percentage, then rounds the value
             $width = round($width * $percentage);
             $height = round($height * $percentage);
         }
         $image = new SimpleImage();
         $image->load($filename);
         $image->resize($width, $height);
         $image->save($cleanFilename);
         $image = null;
     }
     //returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
     return "src=\"{$baseurl}/{$cleanFilename}\"";
 }
开发者ID:dave7y,项目名称:thegamesdb,代码行数:34,代码来源:tab_platform-edit.php

示例8: tearDownAfterClass

 public static function tearDownAfterClass()
 {
     if (!self::$timing) {
         echo "\n";
         return;
     }
     $class = get_called_class();
     echo "Timing results : {$class}\n";
     $s = sprintf("%40s %6s %9s %9s %4s\n", 'name', 'count', 'total', 'avg', '% best');
     echo str_repeat('=', strlen($s)) . "\n";
     echo $s;
     echo str_repeat('-', strlen($s)) . "\n";
     array_walk(self::$timing, function (&$value, $key) {
         $value['avg'] = round($value['total'] / $value['count'] * 1000000, 3);
     });
     usort(self::$timing, function ($a, $b) {
         $at = $a['avg'];
         $bt = $b['avg'];
         return $at === $bt ? 0 : ($at < $bt ? -1 : 1);
     });
     $best = self::$timing[0]['avg'];
     foreach (self::$timing as $timing) {
         printf("%40s %6d %7.3fms %7.3fus %4.1f%%\n", $timing['name'], $timing['count'], round($timing['total'] * 1000, 3), $timing['avg'], round($timing['avg'] / $best * 100, 3));
     }
     echo str_repeat('-', strlen($s)) . "\n\n";
     printf("\nTiming compensated for avg overhead for: timeIt of %.3fus and startTimer/endTimer of %.3fus per invocation\n\n", self::$timeItOverhead * 1000000, self::$startEndOverhead * 1000000);
     parent::tearDownAfterClass();
 }
开发者ID:mean-cj,项目名称:laravel-translation-manager,代码行数:28,代码来源:TranslationManagerTestCase.php

示例9: string

 /**
  * Format value as string
  * @param bool $withUnit
  * @return string
  */
 public function string($withUnit = true)
 {
     if ($this->isUnknown()) {
         return '';
     }
     return round($this->Percent) . ($withUnit ? '&nbsp;' . $this->unit() : '');
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:12,代码来源:Humidity.php

示例10: cuttingimg

function cuttingimg($zoom, $fn, $sz)
{
    @mkdir(WUO_ROOT . '/photos/maps');
    $img = imagecreatefrompng(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
    // получаем идентификатор загруженного изрбражения которое будем резать
    $info = getimagesize(WUO_ROOT . '/photos/maps/0-0-0-' . $fn);
    // получаем в массив информацию об изображении
    $w = $info[0];
    $h = $info[1];
    // ширина и высота исходного изображения
    $sx = round($w / $sz, 0);
    // длинна куска изображения
    $sy = round($h / $sz, 0);
    // высота куска изображения
    $px = 0;
    $py = 0;
    // координаты шага "реза"
    for ($y = 0; $y <= $sz; $y++) {
        for ($x = 0; $x <= $sz; $x++) {
            $imgcropped = imagecreatetruecolor($sx, $sy);
            imagecopy($imgcropped, $img, 0, 0, $px, $py, $sx, $sy);
            imagepng($imgcropped, WUO_ROOT . '/photos/maps/' . $zoom . '-' . $y . '-' . $x . '-' . $fn);
            $px = $px + $sx;
        }
        $px = 0;
        $py = $py + $sy;
    }
}
开发者ID:solodyagin,项目名称:webuseorg3_lite,代码行数:28,代码来源:uploadimageorg.php

示例11: GetRatio

 function GetRatio($UniVisit = false, $UniSome = false)
 {
     if (!$UniVisit || !$UniSome) {
         return 0;
     }
     return round(100 / $UniVisit * $UniSome, 2);
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:7,代码来源:report_parent.class.php

示例12: topic

 public function topic($p = 0)
 {
     $active_key = $this->redis_event_key_prefix . "topics:valid";
     $tid = $this->redis_server->lindex($active_key, $p);
     $topic = $this->redis_server->lindex($this->redis_event_key_prefix . "topics:all", $tid);
     // var_dump($tid);
     // var_dump($topic);
     $topic = $this->formatString($topic);
     // var_dump($topic);
     $topic = json_decode($topic, true);
     //var_dump($topic);
     $events = array();
     foreach ($topic['events'] as $e) {
         $event = $this->redis_server->lindex($this->redis_event_key_prefix . "events", $e);
         //var_dump($event);
         $event = json_decode($this->formatString($event), true);
         //var_dump($event);
         asort($event['keywords']);
         $events[$e] = $event;
     }
     $data['p'] = $p;
     $data['percentage'] = round(100 * ($p + 1.0) / $this->redis_server->llen($active_key), 2);
     $data['topic'] = $topic;
     $data['events'] = $events;
     $this->assign($data);
     $this->display();
     // var_dump($data);
 }
开发者ID:biaochangb,项目名称:website-tools,代码行数:28,代码来源:EventEvolutionController.class.php

示例13: lib_peak_memory

function lib_peak_memory()
{
    $oneMb = 1024 * 1024;
    $memory = memory_get_peak_usage() / $oneMb;
    $memory = round($memory, 4);
    return floatval($memory);
}
开发者ID:kennyma,项目名称:Jolt,代码行数:7,代码来源:Common.php

示例14: Zend_Locale_Math_Sub

function Zend_Locale_Math_Sub($op1, $op2, $op3 = null)
{
    if (empty($op1)) {
        $op1 = 0;
    }
    $result = $op1 - $op2;
    if ((string) ($result + $op2) != (string) $op1) {
        /**
         * @see Zend_Locale_Math_Exception
         */
        require_once 'Zend/Locale/Math/Exception.php';
        throw new Zend_Locale_Math_Exception("subtraction overflow: {$op1} - {$op2} != {$result}", $op1, $op2, $result);
    }
    if ($op3 != 0) {
        $result = round($result, $op3);
    } else {
        if ($result > 0) {
            $result = floor($result);
        } else {
            $result = ceil($result);
        }
    }
    if ($op3 > 0) {
        if ((string) $result == "0") {
            $result = "0.";
        }
        if (strlen($result) < $op3 + 2) {
            $result = str_pad($result, $op3 + 2, "0", STR_PAD_RIGHT);
        }
    }
    return $result;
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:32,代码来源:PhpMath.php

示例15: checkout_form

 public function checkout_form($order_id, $button_text = null)
 {
     if (empty($button_text)) {
         $button_text = 'Перейти к оплате';
     }
     $order = $this->orders->get_order((int) $order_id);
     $payment_method = $this->payment->get_payment_method($order->payment_method_id);
     $payment_currency = $this->money->get_currency(intval($payment_method->currency_id));
     $settings = $this->payment->get_payment_settings($payment_method->id);
     $price = round($this->money->convert($order->total_price, $payment_method->currency_id, false), 2);
     // описание заказа
     // order description
     $desc = 'Оплата заказа №' . $order->id;
     // Способ оплаты
     $paymode = $settings['pay2pay_paymode'];
     $success_url = $this->config->root_url . '/order/';
     $result_url = $this->config->root_url . '/payment/Pay2Pay/callback.php';
     $currency = $payment_currency->code;
     if ($currency == 'RUR') {
         $currency = 'RUB';
     }
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n            <request>\r\n              <version>1.2</version>\r\n              <merchant_id>" . $settings['pay2pay_merchantid'] . "</merchant_id>\r\n              <language>ru</language>\r\n              <order_id>{$order->id}</order_id>\r\n              <amount>{$price}</amount>\r\n              <currency>{$currency}</currency>\r\n              <description>{$desc}</description>\r\n              <result_url>{$result_url}</result_url>\r\n              <success_url>{$success_url}</success_url>\r\n              <fail_url>{$success_url}</fail_url>";
     if ($settings['pay2pay_testmode'] == '1') {
         $xml .= "<test_mode>1</test_mode>";
     }
     $xml .= "</request>";
     $xml_encoded = base64_encode($xml);
     $merc_sign = $settings['pay2pay_secret'];
     $sign_encoded = base64_encode(md5($merc_sign . $xml . $merc_sign));
     $button = '<form action="https://merchant.pay2pay.com/?page=init" method="POST" />' . '<input type="hidden" name="xml" value="' . $xml_encoded . '" />' . '<input type="hidden" name="sign" value="' . $sign_encoded . '" />' . '<input type="submit" class="checkout_button" value="' . $button_text . '">' . '</form>';
     return $button;
 }
开发者ID:gitter-badger,项目名称:Simpla,代码行数:32,代码来源:Pay2Pay.php


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