Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1287643

    Kade McConville
    Participant

    Hi Guys,

    I’m getting an error on my page in relation to this .php code;

    function number_format_i18n( $number, $decimals = 0 ) {
    global $wp_locale;
    if ( isset( $wp_locale ) ) {
    $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] );
    } else {
    $formatted = number_format( $number, absint( $decimals ) );
    }
    /**
    * Filters the number formatted based on the locale

    The error is…

    Warning: number_format() expects parameter 1 to be double, string given in /MYSITE/functions.php on line 219

    Can anyone advise please? 🙂

    #1287875

    Darshana
    Moderator

    Hi there,

    This is not a theme specific issue. However it seems that you’re passing a string into this function.

    Try casting as follows for example:

    
    number_format((float)$number
    

    Thanks!