PHP number: decimal point visible only if needed

后端 未结 12 1582
死守一世寂寞
死守一世寂寞 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:28

    Actually I think the cleanest way I can think of to do this for someone that just did a search looking for this sort of thing is to do this:

    ( number_format ($sql_result["col_number"], 2) * 100 ) / 100;
    

提交回复
热议问题