PHP String to Float

前端 未结 8 1256
别跟我提以往
别跟我提以往 2020-11-28 05:37

I am not familiar with PHP at all and had a quick question.

I have 2 variables pricePerUnit and InvoicedUnits. Here\'s the code that is set

8条回答
  •  無奈伤痛
    2020-11-28 05:59

    Dealing with markup in floats is a non trivial task. In the English/American notation you format one thousand plus 46*10-2:

    1,000.46
    

    But in Germany you would change comma and point:

    1.000,46
    


    This makes it really hard guessing the right number in multi-language applications.
    I strongly suggest using Zend_Measure of the Zend Framework for this task. This component will parse the string to a float by the users language.

提交回复
热议问题