We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26388
    • 103 Posts
    What do I need to adjust - and how - for the output to look like: 3,195 huh

    Note the comma and no decimal places . .

    Thanks!

    <?
    #
    if (!function_exists(format_number)) {
    #
    function format_number($str,$decimal_places='2',$decimal_padding="0"){
    #
    /* taken from http://us2.php.net/manual/en/function.number-format.php#54799 */
    #
    /* firstly format number and shorten any extra decimal places */
    #
    /* Note this will round off the number pre-format $str if you dont want this fucntionality */
    #
    $str = number_format($str,$decimal_places,'.',''); // will return 12345.67
    #
    $number = explode('.',$str);
    #
    $number[1] = (isset($number[1]))?$number[1]:''; // to fix the PHP Notice error if str does not contain a decimal placing.
    #
    $decimal = str_pad($number[1],$decimal_places,$decimal_padding);
    #
    return (float) $number[0].'.'.$decimal;
    #
    }
    #
    }
    #
    return format_number($output);
          ?>