Number helper library.
Methods to make numbers more readable.
_numberFormat( float $value , integer $places 0 , string $decimals '.' , string $thousands ',' )
Alternative number_format() to accommodate multibyte decimals and thousands < PHP 5.4
$value $places optional 0 $decimals optional '.' $thousands optional ',' stringaddFormat( string $formatName , array $options )
Add a currency format to the Number helper. Makes reusing currency formats easier.
$number->addFormat('NOK', array('before' => 'Kr. '));
You can now use NOK as a shortform when formatting currency amounts.
$number->currency($value, 'NOK');
Added formats are merged with the defaults defined in CakeNumber::$_currencyDefaults See CakeNumber::currency() for more information on the various options and their function.
$formatName $options NumberHelper::currency()currency( float $value , string $currency null , array $options array() )
Formats a number into a currency format.
wholeSymbol - The currency symbol to use for whole numbers, greater than 1, or less than -1.wholePosition - The position the whole symbol should be placed valid options are 'before' & 'after'.fractionSymbol - The currency symbol to use for fractional numbers.fractionPosition - The position the fraction symbol should be placed valid options are 'before' & 'after'.before - The currency symbol to place before whole numbers ie. '$'. before is an alias for wholeSymbol.after - The currency symbol to place after decimal numbers ie. 'c'. Set to boolean false to use no decimal symbol. eg. 0.35 => $0.35. after is an alias for fractionSymbol
zero - The text to use for zero values, can be a string or a number. ie. 0, 'Free!'places - Number of decimal places to use. ie. 2fractionExponent - Fraction exponent of this specific currency. Defaults to 2.thousands - Thousands separator ie. ','decimals - Decimal separator symbol ie. '.'negative - Symbol for negative numbers. If equal to '()', the number will be wrapped with ( and )escape - Should the output be escaped for html special characters. The default value for this option is controlled by the currency settings. By default all currencies contain utf-8 symbols and don't need this changed. If you require non HTML encoded symbols you will need to update the settings with the correct bytes.$value $currency optional null $options optional array() stringdefaultCurrency( string $currency null )
Getter/setter for default currency
$currency optional null stringformat( float $value , integer $options false )
Formats a number into a currency format.
$value $options optional false stringformatDelta( float $value , array $options array() )
Formats a number into a currency format to show deltas (signed differences in value).
places - Number of decimal places to use. ie. 2fractionExponent - Fraction exponent of this specific currency. Defaults to 2.before - The string to place before whole numbers. ie. '['after - The string to place after decimal numbers. ie. ']'thousands - Thousands separator ie. ','decimals - Decimal separator symbol ie. '.'$value $options optional array() stringfromReadableSize( string $size , mixed $default false )
Converts filesize from human readable string to bytes
$size $default optional false mixed$default on failure if not falseCakeExceptionprecision( float $value , integer $precision 3 )
Formats a number with a level of precision.
$value $precision optional 3 floattoPercentage( float $value , integer $precision 2 , array $options array() )
Formats a number into a percentage string.
Options:
multiply: Multiply the input value by 100 for decimal percentages.$value $precision optional 2 $options optional array() stringtoReadableSize( integer $size )
Returns a formatted-for-humans file size.
$size string
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-CakeNumber.html