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


PHP formatNumber函数代码示例

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


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

示例1: __construct

 public function __construct($new, $unit)
 {
     $absolute = formatNumber($new / $unit);
     $relative = formatNumber($absolute - 1);
     $hundred = formatNumber($absolute * 100);
     if ($absolute > 1) {
         $nominal = 'positive';
     } else {
         if ($absolute = 1) {
             $nominal = 'status-quo';
         } else {
             $nominal = 'negative';
         }
     }
 }
开发者ID:rubends,项目名称:web-backend-oplossingen,代码行数:15,代码来源:classes-begin.php

示例2: formatBytes

function formatBytes($bytes, $precision = 2, $system = 'IEC')
{
    if ($system === 'IEC') {
        $base = 1024;
        $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB');
    } elseif ($system === 'SI') {
        $base = 1000;
        $units = array('B', 'KB', 'MB', 'GB', 'TB');
    }
    $bytes = max(intval($bytes), 0);
    $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base));
    $pow = min($pow, count($units) - 1);
    $bytes /= pow($base, $pow);
    return formatNumber($bytes, $precision) . ' ' . $units[$pow];
}
开发者ID:woshilapin,项目名称:FreshRSS,代码行数:15,代码来源:lib_rss.php

示例3: formatNumber

function formatNumber($v, $noOfDec = 2, $pad = null)
{
    $num = sprintf("%.{$noOfDec}f", (double) $v);
    return $num;
    // this to be fixed latter
    if ($num >= 100000) {
        $num = $num / 100000;
        $num = formatNumber($num);
        $num = $num . "Lakh";
    } else {
        if ($num >= 1000) {
            $num = $num / 1000;
            $num = formatNumber($num);
            $num = $num . "<b> K </b>";
        }
    }
}
开发者ID:aranyak-banerjee,项目名称:eetpl-connect,代码行数:17,代码来源:commonFunctions_helper.php

示例4: parseContacts

function parseContacts($filename)
{
    $contacts = array();
    $handle = fopen($filename, 'r');
    $contents = fread($handle, filesize($filename));
    $contactsString = trim($contents);
    $contactsArray = explode("\n", $contactsString);
    $newArray = [];
    fclose($handle);
    foreach ($contactsArray as $value) {
        $personInfoArray = explode("|", $value);
        $personInfoArray[1] = formatNumber($personInfoArray[1]);
        //next line is saying you are pushing info(associative array) into newArray.
        $newArray[] = ['name' => $personInfoArray[0], 'number' => $personInfoArray[1]];
    }
    // array literal notation is this [].
    // todo - read file and parse contacts
    return $newArray;
}
开发者ID:ryanski,项目名称:Codeup-Web-Exercises,代码行数:19,代码来源:contact-parser.php

示例5: sort_my_array

function sort_my_array($arr)
{
    foreach ($arr as $key => $row) {
        $nome[$key] = $row[0];
        $cnpj[$key] = $row[1];
        $usuario[$key] = $row[2];
        $auxVlr = formatNumber($row[3]);
        $valor[$key] = (double) $auxVlr;
        $email[$key] = $row[4];
    }
    if (isset($_GET['ordena'])) {
        switch ($_GET['ordena']) {
            case 'nomeA-emailD-valorD':
                array_multisort($nome, SORT_ASC, $email, SORT_DESC, $valor, SORT_DESC, $arr);
                break;
            case 'nomeD-emailD-valorD':
                array_multisort($nome, SORT_DESC, $email, SORT_DESC, $valor, SORT_DESC, $arr);
                break;
            case 'usuarioA-nomeA-valorD':
                array_multisort($usuario, SORT_ASC, $nome, SORT_ASC, $valor, SORT_DESC, $arr);
                break;
            case 'usuarioD-nomeA-valorD':
                array_multisort($usuario, SORT_DESC, $nome, SORT_ASC, $valor, SORT_DESC, $arr);
                break;
            case 'emailD-nomeD-valorA':
                array_multisort($email, SORT_DESC, $nome, SORT_DESC, $valor, SORT_ASC, $arr);
                break;
            case 'emailA-nomeD-valorA':
                array_multisort($email, SORT_ASC, $nome, SORT_DESC, $valor, SORT_ASC, $arr);
                break;
            case 'valorD-nomeA-emailA':
                array_multisort($valor, SORT_DESC, $nome, SORT_ASC, $email, SORT_ASC, $arr);
                break;
            case 'valorA-nomeA-emailA':
                array_multisort($valor, SORT_ASC, $nome, SORT_ASC, $email, SORT_ASC, $arr);
                break;
            default:
                # code...
                break;
        }
    }
    return $arr;
}
开发者ID:andersonbporto,项目名称:programacao_internet_2015_1,代码行数:43,代码来源:Report.php

示例6: contactInfo

function contactInfo($db, $call)
{
    $contacts = '';
    $q3 = "SELECT ares_contact_type, contact, validity, A.type " . "FROM ares_contact_info A, ares_contact_type B " . "WHERE A.type = B.type AND A.call='" . $call . "'";
    //echo "<p>" . $q3 . ",/p>\n";
    $r3 = getResult($q3, $db);
    while ($row3 = getRow($r3, $db)) {
        $xx = $row3[1];
        if ($row3[3] < 4) {
            $xx = formatNumber($row3[1]);
        }
        if ($row3[2] == 1) {
            $contacts = $contacts . $row3[0] . ": <b>" . $xx . "</b><br>";
        } else {
            $contacts = $contacts . $row3[0] . ": " . $xx . "<br>";
        }
    }
    echo $contacts;
}
开发者ID:jjmcd,项目名称:mi-arpsc,代码行数:19,代码来源:ECcontact.php

示例7: parseContacts

function parseContacts($filename)
{
    $filename = 'contacts.txt';
    $handle = fopen($filename, 'r');
    $contents = fread($handle, filesize($filename));
    //$keys = array('name','number');
    $trimContent = trim($contents);
    $contacts = array();
    $formatArray = [];
    $contactsArray = explode("\n", $trimContent);
    //$contacts=explode('|',$contents);
    fclose($handle);
    foreach ($contactsArray as $value) {
        $personInfoArray = explode('|', $value);
        $personInfoArray[1] = formatNumber($personInfoArray[1]);
        $formatArray[] = ['name' => $personInfoArray[0], 'number' => $personInfoArray[1]];
    }
    // todo - read file and parse contacts
    return $formatArray;
}
开发者ID:pswantner,项目名称:Codeup-Web-Excercises,代码行数:20,代码来源:contact-parser.php

示例8: foreach

    //get current values
    $sth = $dbh->prepare('SELECT *
			FROM ' . $TYPES[$_POST['type']]['pluralName'] . '
			WHERE ' . $TYPES[$_POST['type']]['idName'] . ' = :id');
    $sth->execute([':id' => $_POST['id']]);
    $item = $sth->fetch();
    $return['html'] = '<h1>Edit ' . $_POST['type'] . '</h1>';
    foreach ($TYPES[$_POST['type']]['formData'] as $key => $section) {
        $return['html'] .= '<section><h2>' . $key . '</h2><div class="sectionData">';
        foreach ($section as $column) {
            $return['html'] .= '<ul>';
            foreach ($column as $field) {
                $formalName = $TYPES[$_POST['type']]['fields'][$field]['formalName'];
                $attributes = $TYPES[$_POST['type']]['fields'][$field]['verifyData'];
                if ($attributes[1] == 'int' || $attributes[1] == 'dec') {
                    $item[$field] = formatNumber($item[$field]);
                }
                if ($attributes[1] == 'int' || $attributes[1] == 'str' || $attributes[1] == 'dec' || $attributes[1] == 'email') {
                    $return['html'] .= '<li><label for="' . $field . '">' . $formalName . '</label>';
                    $return['html'] .= '<input type="text" name="' . $field . '" autocomplete="off" value="' . $item[$field] . '"></li>';
                } elseif ($attributes[1] == 'id' || $attributes[1] == 'opt') {
                    $empty = $attributes[0] == 0 || $field == 'managerID' && $item[$field] == 0 ? true : false;
                    //allow empty field if it's not required, or if the item is the top employee
                    $return['html'] .= '<li><label for="' . $field . '">' . $formalName . '</label><select name="' . $field . '">';
                    $return['html'] .= $attributes[1] == 'id' ? generateTypeOptions($attributes[2], $empty, $item[$field]) : generateFieldOptions($_POST['type'], $field, $empty, $item[$field]);
                    $return['html'] .= '</select></li>';
                } elseif ($attributes[1] == 'disp') {
                    $return['html'] .= '<li>&nbsp;</li>';
                } elseif ($attributes[1] == 'date') {
                    $return['html'] .= '<li><label for="' . $field . '">' . $formalName . '</label>';
                    $return['html'] .= '<input type="text" class="dateInput" name="' . $field . '" autocomplete="off" value="' . formatDate($item[$field]) . '"></li>';
开发者ID:jewelhuq,项目名称:erp,代码行数:31,代码来源:ajax.php

示例9: getBudgetItemsByBudgetId


//.........这里部分代码省略.........
        $directFee += $smallCount[3];
        $smallCount = array(0, 0, 0, 0, 0, 0);
    }
    //增加一行空行
    $res[$count++] = array('budgetItemId' => 'NULL' . $count, 'budgetId' => $budgetId, 'isEditable' => false);
    //计算其他项
    $totalFee = $directFee;
    //N 工程直接费
    $itemUnit = '元';
    $itemName = '工程直接费';
    $itemCode = 'N';
    $item = $NOPQRSItems[$itemCode];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // O 设计费
    $itemUnit = '元';
    $itemName = '设计费3%';
    $itemCode = 'O';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // P 效果图
    $itemUnit = '张';
    $itemName = '效果图';
    $itemCode = 'P';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = 500 * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    // Q 5%管理费
    $itemUnit = '元';
    $itemName = '5%管理费';
    $itemCode = 'Q';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // R 税金
    $itemUnit = '元';
    $itemName = '税金';
    $itemCode = 'R';
    $item = $NOPQRSItems[$itemCode];
    $itemAmount = $item['itemAmount'];
    $budgetItemId = $item['budgetItemId'];
    $fee = $directFee * $itemAmount;
    $totalFee += $fee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    // S 工程总造价
    $itemUnit = '元';
    $itemName = '工程总造价';
    $itemCode = 'S';
    $item = $NOPQRSItems[$itemCode];
    $budgetItemId = $item['budgetItemId'];
    $itemAmount = '';
    $fee = $totalFee;
    $res[$count++] = array('budgetItemId' => $budgetItemId, 'itemName' => $isGBK ? str2GBK($itemName) : $itemName, 'budgetId' => $budgetId, 'itemCode' => $itemCode, 'itemUnit' => $isGBK ? str2GBK($itemUnit) : $itemUnit, 'itemAmount' => $itemAmount, 'mainMaterialTotalPrice' => $fee, 'isEditable' => false);
    if ($fee != $item['mainMaterialPrice']) {
        $item['mainMaterialPrice'] = $fee;
        $arr = editItem($item);
        // update
    }
    foreach ($res as $count => $bItem) {
        //保留小数点后两位,不足补0
        foreach ($bItem as $key => $val) {
            if (!in_array($key, array('itemAmount', 'mainMaterialTotalPrice', 'auxiliaryMaterialTotalPrice', 'manpowerTotalPrice', 'mainMaterialTotalCost', 'lossPercent', 'manpowerTotalCost', 'machineryTotalPrice', 'mainMaterialPrice', 'auxiliaryMaterialPrice', 'machineryPrice', 'manpowerPrice'))) {
                continue;
            }
            $res[$count][$key] = formatNumber($val);
        }
    }
    return $res;
}
开发者ID:hxghxg527,项目名称:FamilyDecoration,代码行数:101,代码来源:budgetDB.php

示例10: formatNumber_money

function formatNumber_money($value)
{
    return formatNumber($value, 'intmoney');
}
开发者ID:vikingkarwur,项目名称:smjgpib,代码行数:4,代码来源:donByMonth.php

示例11: reset

            <th>Count</th>
        </tr>
    </thead>
    <tbody>
        <?php 
reset($count);
$whole_size = $statistics->getSize();
for ($i = 0; $i < sizeof($count) - 1; $i++) {
    $key = key($count);
    ?>
            <tr>
                <td><?php 
    echo $key;
    ?>
</td>
                <td><?php 
    echo formatSizeNumber($whole_size[$key]);
    ?>
</td>
                <td><?php 
    echo formatNumber($count[$key]);
    ?>
</td>
            </tr>
            <?php 
    next($count);
}
?>
    </tbody>
</table>
开发者ID:rootfs,项目名称:robinhood,代码行数:30,代码来源:count.php

示例12: array

echo "<h1>User " . $user . "</h1>";
echo "<hr/>";
global $sz_range_fields;
global $sz_range_name;
// summary table
$tab = array(array());
$i = 0;
foreach ($user_info as $g => $vals) {
    if ($vals[COUNT] > 0) {
        $avg = round($vals[SIZE] / $vals[COUNT], 0);
    } else {
        $avg = 0;
    }
    $tab[$i][] = "{$user}/{$g}";
    $tab[$i][] = formatSizeNumber($vals[SIZE]);
    $tab[$i][] = formatNumber($vals[COUNT]);
    $tab[$i][] = formatSizeNumber($avg);
    $i++;
}
$header = "<thead> <tr>";
$header = $header . "<th>User/Group</th>";
$header = $header . "<th>Volume</th>";
$header = $header . "<th>File count</th>";
$header = $header . "<th>Avg Size</th>";
$header = $header . "</tr> </thead>";
generateMergedTable($tab, $header);
// profile table
$sz_ranges = array();
$tab = array(array());
$header = "<thead> <tr>";
foreach ($sz_range_name as $range) {
开发者ID:rootfs,项目名称:robinhood,代码行数:31,代码来源:popup.php

示例13: anchor

        echo anchor('invoices/view/' . $row->id, $row->invoice_number);
        ?>
</td>
		<td><?php 
        echo anchor('invoices/view/' . $row->id, $display_date);
        ?>
</td>
		<td class="cName"><?php 
        echo anchor('invoices/view/' . $row->id, $row->name);
        ?>
 <span class="short_description"><?php 
        echo $short_description[$row->id];
        ?>
</span></td>
		<td><?php 
        echo anchor('invoices/view/' . $row->id, formatNumber($row->subtotal, TRUE));
        ?>
</td>
		<td>
		<?php 
        if ($row->amount_paid == $row->subtotal) {
            // paid invoices
            echo anchor('invoices/view/' . $row->id, $this->lang->line('invoice_closed'), array('title' => 'invoice status'));
        } elseif ($row->amount_paid > $row->subtotal) {
            // invoices with credit.
            echo anchor('invoices/view/' . $row->id, $this->lang->line('invoice_with_credit'), array('title' => 'invoice status'));
        } elseif (mysql_to_unix($row->dateIssued) >= strtotime('-' . $this->settings_model->get_setting('days_payment_due') . ' days')) {
            // owing less then the overdue days amount
            echo anchor('invoices/view/' . $row->id, $this->lang->line('invoice_open'), array('title' => 'invoice status'));
        } else {
            // owing more then the overdue days amount
开发者ID:skarcha,项目名称:BambooInvoice,代码行数:31,代码来源:invoice_table.php

示例14: key

$count = $statistics->getCount();
for ($i = 0; $i < sizeof($top_size) - 1; $i++) {
    $group = key($top_size);
    ?>
            <tr>
                <td>
                    <?php 
    echo "<a href='" . str_replace(" ", "%20", $group) . "_group_popup.php'rel='#volume'>" . $group . "</a>";
    ?>
                </td>
                <td><?php 
    echo formatSizeNumber($top_size[$group]);
    ?>
</td>
                <td><?php 
    echo formatNumber($count[$group]);
    ?>
</td>
            </tr>
            <?php 
    next($top_size);
}
?>
    </tbody>
</table>

<!-- POPUP -->
<div class="apple_overlay" id="volume">
    <div class="contentWrap"></div>
</div>
开发者ID:rootfs,项目名称:robinhood,代码行数:30,代码来源:volume.php

示例15: trackingTotalCost

 /**
  * Computer total cost of a ticket
  *
  * @param $actiontime float : ticket actiontime
  * @param $cost_time float : ticket time cost
  * @param $cost_fixed float : ticket fixed cost
  * @param $cost_material float : ticket material cost
  * @param $edit boolean : used for edit of computation ?
  *
  * @return total cost formatted string
  **/
 static function trackingTotalCost($actiontime, $cost_time, $cost_fixed, $cost_material, $edit = true)
 {
     return formatNumber($actiontime * $cost_time / HOUR_TIMESTAMP + $cost_fixed + $cost_material, $edit);
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:15,代码来源:ticket.class.php


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