bp_core_number_format

Format numbers the BuddyPress way.

Description

(string) bp_core_number_format( (int) $number = 0, (bool) $decimals = false ); 

Returns (string)

The formatted number.

Parameters (2)

0. $number — Optional. (int)
The number to be formatted.
1. $decimals — Optional. (bool) => false
The decimals.

Usage

  1. if ( !function_exists( 'bp_core_number_format' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-functions.php'; 
  3.  
  4. // The number to be formatted. 
  5. $number = -1; 
  6.  
  7. // The decimals. 
  8. $decimals = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_core_number_format($number, $decimals); 
  12.  

Defined (1)

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

/bp-core/bp-core-functions.php  
  1. function bp_core_number_format( $number = 0, $decimals = false ) { 
  2.  
  3. // Force number to 0 if needed. 
  4. if ( ! is_numeric( $number ) ) { 
  5. $number = 0; 
  6.  
  7. /** 
  8. * Filters the BuddyPress formatted number. 
  9. * @since 1.2.4 
  10. * @param string $value BuddyPress formatted value. 
  11. * @param int $number The number to be formatted. 
  12. * @param bool $decimals Whether or not to use decimals. 
  13. */ 
  14. return apply_filters( 'bp_core_number_format', number_format_i18n( $number, $decimals ), $number, $decimals );