How to format the number in php by removing fractions

Asked

Viewed 43 times

0

Guys below I put the code just to understand what I want

I want the following value 27.588877333333 print only 27 removing the other numbers as could do this with php

<?php
    $numero = 27.588877333333;
    echo number_format($numero, 0, '', '');
?>
  • 1

    $numero = 27.588877333333; $partes = explode(".", $numero); echo $partes[0];

  • Boy you in front always equal to SKY kkk thanks buddy

  • Thanks bro worked out !

  • echo floor(27.588877333333); returns 27

  • round() - Round a number up or down. Ceil() - Round fractions up. echo floor(27.588877333333); round down

  • Yeah and see that same round() got 28 more worth also got top !

  • by choosing the answer, your question is not correct. Quero o seguinte que o valor 27.588877333333 imprima apenas 27 echo round(27.588877333333); will 28

  • See PHP math functions in http://www.php.net/manual/en/ref.math.php

Show 3 more comments

1 answer

0

Use the function ceil:

<?php
    $numero = 27.588877333333;
    echo ceil($numero);
?>
  • Thanks buddy already worked out here blz !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.