Class NumberHelper

(line 24)

Description


Located in File: /AkActionView/helpers/number_helper.php

Provides methods for converting a number into a formatted string that currently represents one of the following forms: phone number, percentage, money, or precision level.


Class Variables

Summary:

Class Constants

Summary:

Method Detail

Summary:
void human_size ( $size)
void human_size_to_bytes ( $size)
void number_to_currency ( $number, [ $options = array()])
void number_to_human_size ( $size, [ $decimal = 1])
void number_to_percentage ( $number, [ $options = array()])
void number_to_phone ( $number, [ $options = array()])
void number_with_delimiter ( $number, [ $delimiter = ','])
void number_with_precision ( $number, [ $precision = 3])
void zeropad ( $number,  $length)

Method human_size (line 144)

void human_size( $size)

Parameters

  • $size:

Info

Method human_size_to_bytes (line 149)

void human_size_to_bytes( $size)

Parameters

  • $size:

Info

Method number_to_currency (line 72)

void number_to_currency( $number, [ $options = array()])

Formats a +number+ into a currency string. The +options+ array can be used to customize the format of the output.

The +number+ can contain a level of precision using the +precision+ key; default is 2 The currency type can be set using the +unit+ key; default is "$" The unit separator can be set using the +separator+ key; default is "." The delimiter can be set using the +delimiter+ key; default is "," Examples: $number_helper->number_to_currency(1234567890.50) => $1,234,567,890.50 $number_helper->number_to_currency(1234567890.506) => $1,234,567,890.51 $number_helper->number_to_currency(1234567890.50, array('unit' => "£", 'separator' => ",", 'delimiter' => "")) => £1234567890,50 $number_helper->number_to_currency(1234567890.50, array('unit' => " €", 'separator' => ",", 'delimiter' => ".", 'unit_position' => 'right')) => 1.234.567.890,50 €

Parameters

  • $number:
  • $options:

Info

Method number_to_human_size (line 130)

void number_to_human_size( $size, [ $decimal = 1])

Parameters

  • $size:
  • $decimal:

Info

Method number_to_percentage (line 96)

void number_to_percentage( $number, [ $options = array()])

Formats a +number+ as into a percentage string. The +options+ array can be used to customize the format of the output.

The +number+ can contain a level of precision using the +precision+ key; default is 2 The unit separator can be set using the +separator+ key; default is "." Examples: $number_helper->number_to_percentage(100) => 100.00% $number_helper->number_to_percentage(100, array('precision' => 0)) => 100% $number_helper->number_to_percentage(302.0576, array('precision' => 3)) => 302.058%

Parameters

  • $number:
  • $options:

Info

Method number_to_phone (line 37)

void number_to_phone( $number, [ $options = array()])

Formats a +number+ into a US phone number string. The +options+ can be a array used to customize the format of the output.

The area code can be surrounded by parentheses by setting +area_code+ to true; default is false The delimiter can be set using +delimiter+; default is "-" Examples: $number_helper->number_to_phone(1235551234) => 123-555-1234 $number_helper->number_to_phone(1235551234, array('area_code' => true)) => (123) 555-1234 $number_helper->number_to_phone(1235551234, array('delimiter' => " ")) => 123 555 1234 $number_helper->number_to_phone(1235551234, array('area_code' => true, 'extension' => 555)) => (123) 555-1234 x 555

Parameters

  • $number:
  • $options:

Info

Method number_with_delimiter (line 114)

void number_with_delimiter( $number, [ $delimiter = ','])

Formats a +number+ with a +delimiter+.

Example: $number_helper->number_with_delimiter(12345678) => 12,345,678

Parameters

  • $number:
  • $delimiter:

Info

Method number_with_precision (line 166)

void number_with_precision( $number, [ $precision = 3])

Formats a +number+ with a level of +precision+.

Example: $number_helper->number_with_precision(111.2345) => 111.235

Parameters

  • $number:
  • $precision:

Info

Method zeropad (line 187)

void zeropad( $number, $length)

Add zeros to the begining of the string until it reaches desired length

Example: $number_helper->zeropad(123, 6) => 000123

Parameters

  • $number:
  • $length:

Info

Inherited Variables

Inherited Class Variable Summary

Inherited Methods

Inherited Method Summary


Documentation generated on Sat, 06 Oct 2007 03:52:33 +0200 by phpDocumentor 1.3.2