PHP number: decimal point visible only if needed

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

    Mine since most quantity or pieces do not require decimal, this function will only show decimal when needed.

    str_replace(".00", "", number_format($this->pieces, 2));
    

提交回复
热议问题