Simple math with decimals in PHP

后端 未结 4 1209
抹茶落季
抹茶落季 2021-01-22 05:11

This is killing me! I\'ve never had so much trouble and I can\'t figure out what I\'m doing wrong here.

If I have a number, say 2.32, and I want to do math with it it wo

4条回答
  •  不要未来只要你来
    2021-01-22 05:45

    You need to assign $income in the following manner to get rid of the underlying SimpleXMLElement:

    $income = (float) $commission;
    

    Example of what happens when you don't:

    $x = simplexml_load_string("2.4");
    echo $x * 100; // output:  200
    

提交回复
热议问题