App Directory >> CakePHP NumberHelper by Ajay Anturkar
CakePHP NumberHelper
The NumberHelper contains convenience methods that enable display numbers in common formats in your views. These methods include ways to format currency, percentages, data sizes, format numbers to specific precisions and also to give you more flexibility with formating numbers.All of these functions return the formated number; They do not automatically echo the output into the view.
- Uses "CakePHP i18n + l10n" component by Diogo ResendeDiogo Resende with some modifications
Functions
- currency(mixed $number, string $currency= 'USD', $options = array())
- precision (mixed $number, int $precision = 3)
- toPercentage(mixed $number, int $precision = 2)
- toReadableSize(string $data_size)
- format (mixed $number, mixed $options=false)
How to use
$number = get::helper('number');
echo $number->currency("1234.56", "USD")// Output: $1,234.56
App Files
- mvc
- components
- helpers