blob: 20acdec180f5b95e72e155568dbb5b08f49dcfb6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#############
Number Helper
#############
The Number Helper file contains functions that help you work with
numeric data.
.. contents::
:local:
.. raw:: html
<div class="custom-index container"></div>
Loading this Helper
===================
This helper is loaded using the following code::
$this->load->helper('number');
Available Functions
===================
The following functions are available:
.. php:function:: byte_format($num[, $precision = 1])
:param mixed $num: Number of bytes
:param int $precision: Floating point precision
:returns: Formatted data size string
:rtype: string
Formats numbers as bytes, based on size, and adds the appropriate
suffix. Examples::
echo byte_format(456); // Returns 456 Bytes
echo byte_format(4567); // Returns 4.5 KB
echo byte_format(45678); // Returns 44.6 KB
echo byte_format(456789); // Returns 447.8 KB
echo byte_format(3456789); // Returns 3.3 MB
echo byte_format(12345678912345); // Returns 1.8 GB
echo byte_format(123456789123456789); // Returns 11,228.3 TB
An optional second parameter allows you to set the precision of the
result::
echo byte_format(45678, 2); // Returns 44.61 KB
.. note:: The text generated by this function is found in the following
language file: *language/<your_lang>/number_lang.php*
.. php:function:: ordinal_format($number)
:param int $number: Non-negative natural number to be converted
:returns: Ordinal numeral for given number or FALSE on failure
:rtype: string
Returns the ordinal numeral (1st, 2nd, 3rd etc.) for a
non-negative natural number. If the input is not a natural number
greater than 0, the function will return boolean FALSE. Examples::
echo ordinal_format(1); // Returns 1st
echo ordinal_format(3); // Returns 3rd
echo ordinal_format(21); // Returns 21st
echo ordinal_format(102); // Returns 102nd
|