bbp_number_format

A bbPress specific method of formatting numeric values.

Description

(string) bbp_number_format( (int) $number = 0, (constant) $decimals = false, (string) $dec_point = '.', (string) $thousands_sep = ',' ); 

Returns (string)

Formatted string

Parameters (4)

0. $number — Optional. (int)
Number to format
1. $decimals — Optional. (constant) => false
Display decimals
2. $dec_point — Optional. (string) => '.'
The dec point.
3. $thousands_sep — Optional. (string) => ','
The thousands sep.

Usage

  1. if ( !function_exists( 'bbp_number_format' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/common/functions.php'; 
  3.  
  4. // Number to format 
  5. $number = -1; 
  6.  
  7. // Optional. Display decimals 
  8. $decimals = false; 
  9.  
  10. // The dec point. 
  11. $dec_point = '.'; 
  12.  
  13. // The thousands sep. 
  14. $thousands_sep = ','; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = bbp_number_format($number, $decimals, $dec_point, $thousands_sep); 
  18.  

Defined (1)

The function is defined in the following location(s).

/includes/common/functions.php  
  1. function bbp_number_format( $number = 0, $decimals = false, $dec_point = '.', $thousands_sep = ', ' ) { 
  2.  
  3. // If empty, set $number to (int) 0 
  4. if ( ! is_numeric( $number ) ) 
  5. $number = 0; 
  6.  
  7. return apply_filters( 'bbp_number_format', number_format( $number, $decimals, $dec_point, $thousands_sep ), $number, $decimals, $dec_point, $thousands_sep );