How do you round it up in PHP?

Asked

Viewed 205 times

5

What is the function of to round up?

Example:

1.1 move on to 2

4 answers

9


  • My vows are over, then I vote for the others.

  • what we can do when so many equal answers arise?

  • I simply accept what is most voted and that’s that

  • @Wallacemaxters don’t have much to do. In this case no one copied from anyone (who would no longer have much to do but comment for the person to avoid this).

  • @Wallacemaxters do not find it necessary. Yours and even others to a lesser degree have different characteristics that can help in general understanding.

  • ok. I added more information.

  • They are giving +1 sick now. Is the intention to generate "removed serial votes" on purpose? kkkkkk

  • @Wallacemaxters this does not reverse.

Show 3 more comments

4

In PHP to top up is used the function ceil.

Example

echo ceil(4.3);    // 5

4

Use the function ceil.

ceil(1.1); // Imprime 2

This function is usually used to know the number of pages that will be generated in a pagination.

Example:

$total = 100;
$limit = 12;
$pages = ceil($total / $limit); // Imprime 9

It serves to round fractions up.

Just so you have information adds: The function contrary to this is floor. She rounds it down.

2

<?php
echo ceil(1.1);  // 2
echo ceil(4.3);    // 5
echo ceil(9.999);  // 10
echo ceil(-3.14);  // -3
?>

Browser other questions tagged

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