PHP - Force integer conversion to float with three decimals

后端 未结 1 1434
暗喜
暗喜 2020-12-19 22:18

I am trying to convert a big array of numbers to a specific format which is +/-NNN.NNN. So, if I have these numbers:

$numbers1 = array(-1.23, 0.3222, 10, 5.5         


        
相关标签:
1条回答
  • 2020-12-19 22:59

    Try using sprintf()

    $numbers2[] = sprintf("%+07.3f", $fnum);
    
    0 讨论(0)
提交回复
热议问题