How to turn number from float into closest whole number php? -


i have form write number , print other numbers until reach "x" number. when write 33.3 output 34.3, 35.3, 36.3 , etc. if 'x' number 100 last printed number 99.3 :/ how can make last printed number int number? , how can make second number 34.3 34? if possible write examples :)

here 1 way it.

<?php  $number = 96.3; $x = 100;  while ($number <= $x) {     echo $number;     if ($number != $x) {         echo ', ';     }     $number = intval($number) + 1; } 

output:

96.3, 97, 98, 99, 100 

intval truncate fractional part of number , convert integer. add 1 number on each iteration of loop until reach x.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo