wc_float_to_string

Convert a float to a string without locale formatting which PHP adds when changing floats to strings.

Description

(string) wc_float_to_string( (float) $float ); 

Returns (string)

Parameters (1)

0. $float (float)
The float.

Usage

  1. if ( !function_exists( 'wc_float_to_string' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The float. 
  5. $float = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_float_to_string($float); 
  9.  

Defined (1)

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

/includes/wc-formatting-functions.php  
  1. function wc_float_to_string( $float ) { 
  2. if ( ! is_float( $float ) ) { 
  3. return $float; 
  4.  
  5. $locale = localeconv(); 
  6. $string = strval( $float ); 
  7. $string = str_replace( $locale['decimal_point'], '.', $string ); 
  8.  
  9. return $string;