PHP number: decimal point visible only if needed

后端 未结 12 1784
死守一世寂寞
死守一世寂寞 2021-01-31 06:48

I\'d like to know if exists some function to automatically format a number by it\'s decimal, so if I have:



        
12条回答
  •  灰色年华
    2021-01-31 07:43

    Warren.S answer helped me out. I didn't need the number_format function, so I just did this

    $value=$value-0;
    

    But in the OP's case, he needs number_format to remove the commas. So this would work for him

    $value=number_format ($sql_result["col_number"], 2, ".", "")-0;
    

提交回复
热议问题