Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End how to convert float to this

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #41866
    amis
    Participant

    I wonder how can i convert float to …

    $x = 12.548544444
    to
    $x = 12.55

    #120374
    hotpink
    Member

    This can be reduced to a single operation by passing a 2nd argument to the round() function.

    $x = 12.548544444;
    $x = round($x, 2);

    The “2” tells it to round two places past the decimal.

    http://php.net/manual/en/function.round.php

    #120375
    amis
    Participant

    thx very much for helping me

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.