How to get whole and decimal part of a number?

前端 未结 16 1226
名媛妹妹
名媛妹妹 2020-11-27 03:10

Given, say, 1.25 - how do I get \"1\" and .\"25\" parts of this number?

I need to check if the decimal part is .0, .25, .5, or .75.

16条回答
  •  佛祖请我去吃肉
    2020-11-27 03:57

    This code will split it up for you:

    list($whole, $decimal) = explode('.', $your_number);
    

    where $whole is the whole number and $decimal will have the digits after the decimal point.

提交回复
热议问题