symfony API

sfNumberFormat Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.2 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

sfNumberFormat class.

Method Summary

  • fixFloat($float)
  • string format($number, $pattern = 'd', $currency = 'USD', $charset = 'UTF-8')
    Formats the number for a certain pattern. The valid patterns are 'c', 'd', 'e', 'p' or a custom pattern, such as "#.000" for 3 decimal places.
  • string formatDecimal($string)
    Formats the decimal places.
  • string formatInteger($string)
    Formats the integer, perform groupings and string padding.
  • string setPattern($pattern)
    Sets the pattern to format against. The default patterns are retrieved from the sfNumberFormatInfo instance.
  • constructor __construct($formatInfo = null)
    Creates a new number format instance. The constructor can be instantiated with a string that represent a culture/locale. Similarly, passing a sfCultureInfo or sfNumberFormatInfo instance will instantiated a instance for that particular culture.

Method Details

  • fixFloat ($float) Browse code

    $float

  • (string) format ($number, $pattern = 'd', $currency = 'USD', $charset = 'UTF-8') Browse code

    $number the number to format.
    $pattern the format pattern, either, 'c', 'd', 'e', 'p' or a custom pattern. E.g. "#.000" will format the number to 3 decimal places.
    $currency 3-letter ISO 4217 code. For example, the code "USD" represents the US Dollar and "EUR" represents the Euro currency.
    $charset The charset

    Formats the number for a certain pattern. The valid patterns are 'c', 'd', 'e', 'p' or a custom pattern, such as "#.000" for 3 decimal places.

    returns formatted number string

  • (string) formatDecimal ($string) Browse code

    $string the decimal number in string form.

    Formats the decimal places.

    returns formatted decimal places.

  • (string) formatInteger ($string) Browse code

    $string the decimal number in string form.

    Formats the integer, perform groupings and string padding.

    returns formatted integer string with grouping

  • (string) setPattern ($pattern) Browse code

    $pattern the requested patterns.

    Sets the pattern to format against. The default patterns are retrieved from the sfNumberFormatInfo instance.

    returns a number format pattern.

  • (constructor) __construct ($formatInfo = null) Browse code

    $formatInfo either null, a sfCultureInfo, a sfNumberFormatInfo, or string

    Creates a new number format instance. The constructor can be instantiated with a string that represent a culture/locale. Similarly, passing a sfCultureInfo or sfNumberFormatInfo instance will instantiated a instance for that particular culture.