direktori cari
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
watak

“数字帮助”文件包含帮助您处理数字数据的函数。

  • 加载此助手

  • 可用职能

加载此助手

使用以下代码加载此助手:

$this->load->helper('number');

可用职能

现有下列职能:

byte_format($num[, $precision = 1])

参数:

$ num(mixed) - 字节数$ precision(int) - 浮点精度

返回:

格式化的数据大小字符串

返回类型:

  • $ num混合) - 字节数

  • $ precisionint) - 浮点精度

Returns:  Formatted data size string
Return type:  string
Formats numbers as bytes, based on size, and adds the appropriate suffix. Examples:

echo byte_format(456); //返回456字节echo byte_format(4567); //返回4.5 KB echo byte_format(45678); //返回44.6 KB echo byte_format(456789); //返回447.8 KB echo byte_format(3456789); //返回3.3 MB echo byte_format(12345678912345); //返回1.8 GB echo byte_format(123456789123456789); //返回11,228.3 TB

可选的第二个参数允许您设置结果的精度:

echo byte_format(45678,2); //返回44.61 KB

该函数生成的文本可在以下语言文件中找到:language / <your_lang> /number_lang.php

Artikel sebelumnya: Artikel seterusnya: