本文整理汇总了PHP中ROUND函数的典型用法代码示例。如果您正苦于以下问题:PHP ROUND函数的具体用法?PHP ROUND怎么用?PHP ROUND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ROUND函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_list
public function get_list($lat, $long, $page, $pagesize, $activity_type)
{
$where = array("status" => 0, "invite_time" => array("gt", time()));
if ($activity_type !== false) {
$sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.activity_type=" . $activity_type . " AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
$where["activity_type"] = intval($activity_type);
} else {
$sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
}
$start = ($page - 1) * $pagesize;
$count = $this->where($where)->count();
$sql .= " limit {$start}, {$pagesize}";
$mode = new Model();
$res = $mode->query($sql);
$today = strtotime(date("Y-m-d")) + 86400;
$tomorrow = $today + 86400;
$lastday = $tomorrow + 86400;
foreach ($res as &$v) {
$v["_time"] = date("Y-m-d H:i", $v["invite_time"]);
$v["juli"] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($lat * PI() / 180 - $v["lat"] * PI() / 180) / 2), 2) + COS($lat * PI() / 180) * COS($v["lat"] * PI() / 180) * POW(SIN(($long * PI() / 180 - $v["long"] * PI() / 180) / 2), 2))) * 1000);
$v["juli"] = 1000 < $v["juli"] ? number_format($v["juli"] / 1000, 1) . "km" : ($v["juli"] < 100 ? "<100m" : $v["juli"] . "m");
$v["invite_time"] = $v["invite_time"] < $today ? "今天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $tomorrow ? "明天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $lastday ? "后天 " . date("H:i", $v["invite_time"]) : date("m-d H:i", $v["invite_time"])));
$v["birthday"] && ($v["age"] = date("Y") - date("Y", strtotime($v["birthday"])));
$v["age"] = 100 < $v["age"] || $v["age"] < 0 ? "保密" : $v["age"] . "岁";
}
return array("data" => $res, "total" => $count);
}
示例2: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
/*for ($i = 1; $i <= 2; $i++) {
$this->command->info('User '.$i);
DB::table('users')->insert(array (
"name" => $faker->userName,
"email" => $faker->unique()->safeEmail,
//"name" => 'embajada77',
//"email" => 'embajada77@gmail.com',
"password" => Hash::make('1234')
));
}*/
$users_array = array();
$tope = 5518;
$cronom = new cronometro();
$password = Hash::make('1234');
for ($i = 1; $i <= $tope; $i++) {
$users_array[$i] = array("name" => $faker->userName, "email" => $faker->unique()->safeEmail, "password" => $password);
$prcnt = ROUND($i * 100 / $tope, 2);
$string_time = $cronom->getTiempoTranscurrido() . ' ' . $cronom->EstimarTiempoRestante($prcnt);
$this->command->info($string_time . ' ' . $prcnt . '% User ' . $i . '/' . $tope);
}
DB::table('users')->insert($users_array);
}
示例3: percentFinishedCalculation
public function percentFinishedCalculation($Time_Min, $esDay, $esHour, $esMin, $finished)
{
$PercentFinished = 0;
if ($finished == 1) {
$PercentFinished = 100;
} else {
$PercentFinished = ROUND($Time_Min / ($esDay * 24 * 60 + $esHour * 60 + $esMin) * 100);
}
return $PercentFinished;
}
示例4: NumberFormat
function NumberFormat($number)
{
if ($number % 8 == 0) {
$number = $number / 8;
$formatNumber = ROUND($number, 0);
} else {
$number = ROUND($number / 8, 0);
$formatNumber = number_format($number, 0);
}
return $formatNumber;
}
示例5: beforeSave
public function beforeSave()
{
if ($this->isNewRecord) {
$this->autor = Yii::app()->user->name;
$this->peso = ROUND($this->archivo->getSize() / 1024, 2);
$this->fechasubida = "" . date("Y-m-d") . "";
$this->extension = "." . $this->archivo->getExtensionName();
$this->ndescargas = 0;
//$this->descridetalle=" ".date("H:i")." -->".$this->descridetalle;
} else {
//$this->ultimares=" ".strtoupper(trim($this->usuario=Yii::app()->user->name))." ".date("H:i")." :".$this->ultimares;
}
return parent::beforeSave();
}
示例6: distribute_toll
function distribute_toll($db, $sector, $toll, $total_fighters)
{
$result3 = $db->Execute("SELECT * FROM {$db->prefix}sector_defence WHERE sector_id=? AND defence_type ='F'", array($sector));
db_op_result($db, $result3, __LINE__, __FILE__);
// Put the defence information into the array "defenceinfo"
if ($result3 > 0) {
while (!$result3->EOF) {
$row = $result3->fields;
$toll_amount = ROUND($row['quantity'] / $total_fighters * $toll);
$resa = $db->Execute("UPDATE {$db->prefix}ships SET credits=credits + ? WHERE ship_id = ?", array($toll_amount, $row['ship_id']));
db_op_result($db, $resa, __LINE__, __FILE__);
playerlog($db, $row['ship_id'], LOG_TOLL_RECV, "{$toll_amount}|{$sector}");
$result3->MoveNext();
}
}
}
示例7: create_bar
public function create_bar($title, $value, $max, $width = 300, $onlyperc = true)
{
$perc = ROUND($value * 100 / $max);
if ($perc > 100) {
$perc = 100;
}
$wcell1 = $width / 100 * $perc;
$wcell2 = $width / 100 * (100 - $perc);
if ($onlyperc) {
$printval = "{$perc}%";
} else {
$printval = "{$value}({$perc}%)";
}
$output .= "<table border=0 cellpadding=0 cellspacing=2 frame=void ><tr><td>{$title}</td><td width={$wcell1}px style='background-color: #888888'><center><strong>{$printval}</strong></center></td><td width={$wcell2} style='background-color: #dddddd'></td></tr></table>";
return $output;
}
示例8: pilot_pay
public static function pilot_pay($pilotid)
{
$ft = "SELECT flighttime FROM phpvms_pireps WHERE pilotid = '{$pilotid}' ORDER BY submitdate DESC";
$flttme = DB::get_row($ft);
$hr = intval($flttme->flighttime);
$mn = ($flttme->flighttime - $hr) * 100;
$min = $hr * 60 + $mn;
$fr = "SELECT pilotpay FROM phpvms_pireps WHERE pilotid = '{$pilotid}' ORDER BY submitdate DESC";
$payrate = DB::get_row($fr);
$pay = $payrate->pilotpay / 60;
$pp = "SELECT totalpay FROM phpvms_pilots WHERE pilotid = '{$pilotid}'";
$ppay = DB::get_row($pp);
$pipay = $payrate->totalpay;
$ftupdt = $min * $pay;
$ttalpay = $ftupdt + $pipay;
$totalpay = ROUND($ttalpay, 2);
$updt = "UPDATE phpvms_pilots SET totalpay = '{$totalpay}' + totalpay WHERE pilotid = '{$pilotid}'";
DB::query($updt);
}
示例9: number_readable
function number_readable($number, $unit = "bytes")
{
if ($unit == "bytes") {
if ($number > 1000000000) {
$number = ROUND($number / 1000000000) . "GB";
} else {
if ($number > 1000000) {
$number = ROUND($number / 1000000) . "MB";
} else {
if ($number > 1000) {
$number = ROUND($number / 1000) . "KB";
}
}
}
} else {
if ($unit == "decimals") {
$number = number_format($number, 0, ".", ",");
}
}
return $number;
}
示例10: while
}
if ($sth->rowCount() >= 1) {
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
//USER REGISTERED/CONFIRMED BNET ACCOUNT
if ($row["user_bnet"] >= 1) {
$sth2 = $db->prepare("SELECT * FROM " . OSDB_STATS . " \r\n\t WHERE player = '" . $row["user_name"] . "' \r\n\t ORDER BY id DESC \r\n\t LIMIT 1 ");
$result = $sth2->execute();
$row2 = $sth2->fetch(PDO::FETCH_ASSOC);
$MemberData[$c]["points"] = number_format($row2["points"]);
$MemberData[$c]["games"] = $row2["games"];
$MemberData[$c]["score"] = $row2["score"];
$MemberData[$c]["wins"] = $row2["wins"];
$MemberData[$c]["losses"] = $row2["losses"];
$MemberData[$c]["uid"] = $row2["id"];
if ($row2["wins"] > 0) {
$MemberData[$c]["winslosses"] = ROUND($row2["wins"] / ($row2["wins"] + $row2["losses"]), 3) * 100;
} else {
$MemberData[$c]["winslosses"] = 0;
}
}
$MemberData[$c]["user_id"] = $row["user_id"];
$MemberData[$c]["user_name"] = $row["user_name"];
$MemberData[$c]["user_bnet"] = $row["user_bnet"];
$MemberData[$c]["user_ppwd"] = $row["user_ppwd"];
$MemberData[$c]["bnet_username"] = $row["bnet_username"];
$MemberData[$c]["user_email"] = $row["user_email"];
$MemberData[$c]["user_level"] = $row["user_level"];
$MemberData[$c]["total_comments"] = $row["total_comments"];
$MemberData[$c]["user_joined"] = date(OS_DATE_FORMAT, $row["user_joined"]);
$MemberData[$c]["user_joined_date"] = $row["user_joined"];
$MemberData[$c]["user_location"] = $row["user_location"];
示例11: getstats
private function getstats()
{
$row = $this->db->get_row("stats");
extract($row);
$efficiency_size = ROUND($localtraffic * 100 / $internettraffic);
$efficiency_hit = ROUND($hit * 100 / $miss);
$localtraffic = number_readable($localtraffic);
$internettraffic = number_readable($internettraffic);
$troughput_internet = number_readable($troughput_internet) . "/sec";
$troughput_local = number_readable($troughput_local) . "/sec";
$res = $this->db->sql("SELECT SUM(size) as size_sum, path FROM `videos` GROUP by path");
foreach ($res as $res1) {
$space[$res1["path"]] = $res1["size_sum"];
}
$this->addtostats("START");
$this->addtostats("Miss: " . number_readable($miss, "decimals"));
$this->addtostats("Hit: " . number_readable($hit, "decimals"));
$this->addtostats("Local traffic: {$localtraffic}");
$this->addtostats("Internet traffic: {$internettraffic}");
$this->addtostats("Connect time: {$connect_time}ms");
$this->addtostats("File access time: {$file_access_time}ms");
$this->addtostats("Internet troughput: {$troughput_internet}");
$this->addtostats("Local troughput: {$troughput_local}");
$vcount = $this->db->sql("select count(*) as cnt from videos");
$count = $vcount[0]["cnt"];
$this->addtostats("Cached videos: " . number_readable($count, "decimals"));
$totalsum = $this->db->sql("SELECT SUM(size) as totalsum FROM `videos`");
$totalsum = $totalsum[0]["totalsum"];
$totalsum = number_readable($totalsum);
$this->addtostats("Total video size: {$totalsum}");
$this->addtostats("Size Efficiency: {$efficiency_size}%");
$this->addtostats("Hit Efficiency: {$efficiency_hit}%");
$lastday = $this->db->sql("select count(*) as cnt from visits where `visit_date`>DATE_SUB(NOW(),INTERVAL 1 DAY)");
$lastday = $lastday[0]["cnt"];
$this->addtostats("Last day hits: " . number_readable($lastday, "decimals"));
$lasthr = $this->db->sql("select count(*) as cnt from visits where `visit_date`>DATE_SUB(NOW(),INTERVAL 1 HOUR)");
$lasthr = $lasthr[0]["cnt"];
$this->addtostats("Last hour hits: " . number_readable($lasthr, "decimals"));
$lastmin = $this->db->sql("select count(*) as cnt from visits where `visit_date`>DATE_SUB(NOW(),INTERVAL 1 MINUTE)");
$lastmin = $lastmin[0]["cnt"];
$this->addtostats("Last minute hits: " . number_readable($lastmin, "decimals"));
$totalsize = 0;
$bars = "";
foreach ($space as $spath => $ssize) {
$stotal = disk_total_space($spath);
$bars .= $this->page_manager->create_bar($spath, $ssize, $stotal, 600, true);
$perc = ROUND($ssize * 100 / $stotal);
$totalsize += $stotal;
$ssize = number_readable($ssize);
$stotal = number_readable($stotal);
$this->addtostats("Store path: <em>{$spath}</em> size <strong>{$ssize} ({$perc}%)</strong> total <strong>{$stotal}</strong>");
}
// storage paths
$this->addtostats("Total storage size: <strong>" . number_readable($totalsize) . "</strong>");
$this->addtostats("END");
$this->content .= $bars . "<br />\n";
}
示例12: foreach
<?php
/*
* Trae el presupuesto asociado al área determinada
*/
$sbNombAre = $_REQUEST['sbNombAre'];
$BeanAreas = BeanFactory::getBean('opalo_area');
if ($sbNombAre != 'ninguno') {
$bnAreas = $BeanAreas->get_full_list('', "opalo_area.name like '{$sbNombAre}'");
$nuRes = 0;
if ($bnAreas != null) {
foreach ($bnAreas as $area) {
$nuRes = $area->nuCostoArea;
}
}
} else {
$nuRes = 0;
}
echo json_encode(ROUND($nuRes, 2));
示例13: OS_DrawStars
function OS_DrawStars($stars = 1, $width = 24)
{
$stars = ROUND($stars);
$LeftStars = 5 - $stars;
if ($stars >= 1) {
for ($x = 1; $x <= $stars; $x++) {
?>
<img class="imgvalign" src="<?php
echo OS_THEME_PATH;
?>
images/star-1.png" width="<?php
echo $width;
?>
" height="<?php
echo $width;
?>
" alt="rating star" /><?php
}
}
if ($LeftStars >= 1) {
for ($x = 1; $x <= $LeftStars; $x++) {
?>
<img class="imgvalign" src="<?php
echo OS_THEME_PATH;
?>
images/star-0.png" width="<?php
echo $width;
?>
" height="<?php
echo $width;
?>
" alt="rating star" /> <?php
}
}
}
示例14: mysql_fetch_assoc
}
//----------------------------------------------------
//--------------------------- კავშირის გაწყვეტის მიზეზეი
$row_COMPLETECALLER = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `count`\n FROM `asterisk_incomming`\n WHERE disconnect_cause != 'ABANDON' \n AND DATE(call_datetime) >= '{$start_time}'\n AND DATE(call_datetime) <= '{$end_time}' \n AND dst_queue IN ({$queue}) \n AND dst_extension in ({$agent})\n AND disconnect_cause = 'COMPLETECALLER'"));
$row_AGENT = mysql_fetch_assoc(mysql_query("SELECT COUNT(*) AS `count`\n FROM `asterisk_incomming`\n WHERE\tdisconnect_cause != 'ABANDON' \n AND DATE(call_datetime) >= '{$start_time}'\n AND DATE(call_datetime) <= '{$end_time}'\n AND dst_queue IN ({$queue})\n AND dst_extension in ({$agent})\n AND disconnect_cause = 'COMPLETEAGENT'"));
$data['page']['disconnection_cause'] = '
<tr>
<td>ოპერატორმა გათიშა:</td>
<td id="close_agent" style="cursor: pointer; text-decoration: underline;">' . $row_AGENT[count] . ' ზარი</td>
<td>' . ROUND($row_AGENT[count] / ($row_COMPLETECALLER[count] + $row_AGENT[count]) * 100, 2) . ' %</td>
</tr>
<tr>
<td>აბონენტმა გათიშა:</td>
<td id="close_celer" style="cursor: pointer; text-decoration: underline;">' . $row_COMPLETECALLER[count] . ' ზარი</td>
<td>' . ROUND($row_COMPLETECALLER[count] / ($row_COMPLETECALLER[count] + $row_AGENT[count]) * 100, 2) . ' %</td>
</tr>';
//-----------------------------------------------
}
if ($_REQUEST['act'] == 'tab_2') {
//----------------------------------- უპასუხო ზარები
$data['page']['unanswer_call'] = '
<tr>
<td>უპასუხო ზარების რაოდენობა:</td>
<td>' . $row_abadon[count] . ' ზარი</td>
</tr>
<tr>
<td>ლოდინის საშ. დრო კავშირის გაწყვეტამდე:</td>
<td>' . $row_abadon[sec] . '</td>
</tr>
示例15: ajout_global_groupe
function ajout_global_groupe($choix_groupe, $tab_new_nb_conges_all, $tab_calcul_proportionnel, $tab_new_comment_all, $DEBUG = FALSE)
{
$PHP_SELF = $_SERVER['PHP_SELF'];
$session = session_id();
// recup de la liste des users d'un groupe donné
$list_users = get_list_users_du_groupe($choix_groupe, $DEBUG);
foreach ($tab_new_nb_conges_all as $id_conges => $nb_jours) {
if ($nb_jours != 0) {
$comment = $tab_new_comment_all[$id_conges];
$sql1 = "SELECT u_login, u_quotite FROM conges_users WHERE u_login IN ({$list_users}) ORDER BY u_login ";
$ReqLog1 = SQL::query($sql1);
while ($resultat1 = $ReqLog1->fetch_array()) {
$current_login = $resultat1["u_login"];
$current_quotite = $resultat1["u_quotite"];
if (!isset($tab_calcul_proportionnel[$id_conges]) || $tab_calcul_proportionnel[$id_conges] != TRUE) {
$nb_conges = $nb_jours;
} else {
// pour arrondir au 1/2 le + proche on fait x 2, on arrondit, puis on divise par 2
$nb_conges = ROUND($nb_jours * ($current_quotite / 100) * 2) / 2;
}
$valid = verif_saisie_decimal($nb_conges, $DEBUG);
if ($valid) {
// 1 : on update conges_solde_user
$req_update = 'UPDATE conges_solde_user SET su_solde = su_solde+ ' . intval($nb_conges) . '
WHERE su_login = \'' . SQL::quote($current_login) . '\' AND su_abs_id = ' . intval($id_conges) . ';';
$ReqLog_update = SQL::query($req_update);
// 2 : on insert l'ajout de conges dans la table periode
// recup du nom du groupe
$groupename = get_group_name_from_id($choix_groupe, $DEBUG);
$commentaire = _('resp_ajout_conges_comment_periode_groupe') . " {$groupename}";
// ajout conges
insert_ajout_dans_periode($DEBUG, $current_login, $nb_conges, $id_conges, $commentaire);
}
}
$group_name = get_group_name_from_id($choix_groupe, $DEBUG);
if (!isset($tab_calcul_proportionnel[$id_conges]) || $tab_calcul_proportionnel[$id_conges] != TRUE) {
$comment_log = "ajout conges pour groupe {$group_name} ({$nb_jours} jour(s)) ({$comment}) (calcul proportionnel : No)";
} else {
$comment_log = "ajout conges pour groupe {$group_name} ({$nb_jours} jour(s)) ({$comment}) (calcul proportionnel : Yes)";
}
log_action(0, "ajout", "groupe", $comment_log, $DEBUG);
}
}
}