CodeIgniter v4.5 API

number_helper.php

This file is part of CodeIgniter 4 framework.

(c) CodeIgniter Foundation admin@codeigniter.com

For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

Table of Contents

Functions

number_to_size()  : bool|string
Formats a numbers as bytes, based on size, and adds the appropriate suffix
number_to_amount()  : bool|string
Converts numbers to a more readable representation when dealing with very large numbers (in the thousands or above), up to the quadrillions, because you won't often deal with numbers larger than that.
number_to_currency()  : string
format_number()  : string
A general purpose, locale-aware, number_format method.
number_to_roman()  : string|null
Convert a number to a roman numeral.

Functions

number_to_size()

Formats a numbers as bytes, based on size, and adds the appropriate suffix

number_to_size(int|string $num[, int $precision = 1 ][, non-empty-string|null $locale = null ]) : bool|string
Parameters
$num : int|string

Will be cast as int

$precision : int = 1
$locale : non-empty-string|null = null

[optional]

Return values
bool|string

number_to_amount()

Converts numbers to a more readable representation when dealing with very large numbers (in the thousands or above), up to the quadrillions, because you won't often deal with numbers larger than that.

number_to_amount(int|string $num[, int $precision = 0 ][, non-empty-string|null $locale = null ]) : bool|string

It uses the "short form" numbering system as this is most commonly used within most English-speaking countries today.

Parameters
$num : int|string

Will be cast as int

$precision : int = 0

[optional] The optional number of decimal digits to round to.

$locale : non-empty-string|null = null

[optional]

Tags
see
https://simple.wikipedia.org/wiki/Names_for_large_numbers
Return values
bool|string

number_to_currency()

number_to_currency(float $num, string $currency[, string|null $locale = null ][, int $fraction = 0 ]) : string
Parameters
$num : float
$currency : string
$locale : string|null = null
$fraction : int = 0
Return values
string

format_number()

A general purpose, locale-aware, number_format method.

format_number(float $num[, int $precision = 1 ][, string|null $locale = null ][, array<string|int, mixed> $options = [] ]) : string

Used by all of the functions of the number_helper.

Parameters
$num : float
$precision : int = 1
$locale : string|null = null
$options : array<string|int, mixed> = []
Return values
string

number_to_roman()

Convert a number to a roman numeral.

number_to_roman(int|string $num) : string|null
Parameters
$num : int|string

it will convert to int

Return values
string|null

        
On this page

Search results