Removing all decimals in PHP

前端 未结 10 2082
囚心锁ツ
囚心锁ツ 2020-12-16 12:27

get this from my database:

252.587254564

Well i wanna remove the .587254564 and keep the 252, how can i do that?

10条回答
  •  独厮守ぢ
    2020-12-16 12:27

    In PHP you would use:

    $value = floor($value);
    

    floor: Returns the next lowest integer value by rounding the value down if necessary.

    If you wanted to round up it would be:

    $value = ceil($value);
    

    ceil: Returns the next highest integer value by rounding the value up if necessary.

提交回复
热议问题