Compare decimals in PHP

后端 未结 3 888
执念已碎
执念已碎 2021-01-28 18:38

I have a form input to get a number (it is a price). It can be a decimal like 102,5. I have to compare it with an other decimal for exemple 102,6. How can handle this ? I don\'

3条回答
  •  长发绾君心
    2021-01-28 19:35

    Just make it decimal out of this format

    $kinda_decimal = "102,5";
    $kinda_decimal = floatval(str_replace(",",".",$kinda_decimal));
    

    and compare it

提交回复
热议问题