Derek Jones | 8ede1a2 | 2011-10-05 13:34:52 -0500 | [diff] [blame] | 1 | ############# |
| 2 | Number Helper |
| 3 | ############# |
| 4 | |
| 5 | The Number Helper file contains functions that help you work with |
| 6 | numeric data. |
| 7 | |
| 8 | .. contents:: Page Contents |
| 9 | |
| 10 | Loading this Helper |
| 11 | =================== |
| 12 | |
| 13 | This helper is loaded using the following code |
| 14 | |
| 15 | :: |
| 16 | |
| 17 | $this->load->helper('number'); |
| 18 | |
| 19 | The following functions are available: |
| 20 | |
| 21 | byte_format() |
| 22 | ============= |
| 23 | |
| 24 | Formats a numbers as bytes, based on size, and adds the appropriate |
| 25 | suffix. Examples |
| 26 | |
| 27 | :: |
| 28 | |
| 29 | echo byte_format(456); // Returns 456 Bytes |
| 30 | echo byte_format(4567); // Returns 4.5 KB |
| 31 | echo byte_format(45678); // Returns 44.6 KB |
| 32 | echo byte_format(456789); // Returns 447.8 KB |
| 33 | echo byte_format(3456789); // Returns 3.3 MB |
| 34 | echo byte_format(12345678912345); // Returns 1.8 GB |
| 35 | echo byte_format(123456789123456789); // Returns 11,228.3 TB |
| 36 | |
| 37 | An optional second parameter allows you to set the precision of the |
| 38 | result. |
| 39 | |
| 40 | :: |
| 41 | |
| 42 | echo byte_format(45678, 2); // Returns 44.61 KB |
| 43 | |
| 44 | .. note:: The text generated by this function is found in the following |
kenjis | 087a7a8 | 2011-10-20 20:08:47 +0900 | [diff] [blame] | 45 | language file: language/<your_lang>/number_lang.php |