Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php round to whole number

$int = 8.998988776636;
round($int) //Will always be 9

$int = 8.344473773737377474;
round($int) //will always be 8
Comment

php round up

//round up to nearest integer
echo(ceil(0.60) . "<br>");
//result 1
Comment

php round up

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

php round to the nearest 10

$number = ceil($input / 10) * 10;
Comment

php round up


<?php
echo 'Rounding modes with 9.5' . PHP_EOL;
var_dump(round(9.5, 0, PHP_ROUND_HALF_UP));
var_dump(round(9.5, 0, PHP_ROUND_HALF_DOWN));
var_dump(round(9.5, 0, PHP_ROUND_HALF_EVEN));
var_dump(round(9.5, 0, PHP_ROUND_HALF_ODD));

echo 'Rounding modes with 8.5' . PHP_EOL;
var_dump(round(8.5, 0, PHP_ROUND_HALF_UP));
var_dump(round(8.5, 0, PHP_ROUND_HALF_DOWN));
var_dump(round(8.5, 0, PHP_ROUND_HALF_EVEN));
var_dump(round(8.5, 0, PHP_ROUND_HALF_ODD));
?>

Comment

php round up

echo ceil(4.3);    // 5
echo ceil(9.999);  // 10
echo ceil(-3.14);  // -3
Comment

round off to 0.5 php

function roundDown($number, $nearest){
    return $number - fmod($number, $nearest);
}

var_dump(roundDown(7.778, 0.5));
var_dump(roundDown(7.501, 0.5));
var_dump(roundDown(7.49, 0.5));
var_dump(roundDown(7.1, 0.5));
Comment

Round the number in php

<?php
$price =3206250;
$bolish = $price / 1000000;
$natija = ceil($bolish);   // 4

echo  $natija *1000000;
Comment

php round nearest half

$x = floor($x * 2) / 2;
Comment

PREVIOUS NEXT
Code Example
Php :: laravel form request custom error message 
Php :: php postgresql number of rows 
Php :: laravel query with trashed 
Php :: fresh migrqte laravel 
Php :: target class admin homecontroller does not exist laravel 8 
Php :: zero padding php 
Php :: install php 5.6 mac 
Php :: PHP MySQL Delete Data 
Php :: how to use xampp for php and mysql 
Php :: laravel grouping where 
Php :: laravel validation get failed rules 
Php :: how to create laravel project 
Php :: get user information woocommerce 
Php :: command to create model with migration in laravel 
Php :: features of PHP7 
Php :: php artisan storage:link not working 
Php :: php cookie 
Php :: laravel hasmany relationship 
Php :: php extract month and year from date 
Php :: php convert print_r to array 
Php :: convert string to float in php 
Php :: php PDO database crud class 
Php :: the requested php extension bcmath is missing from your system 
Php :: call function in php 
Php :: how to create access token in laravel 
Php :: - root composer.json requires php ^7.2 but your php version (8.0.1) does not satisfy that requirement. 
Php :: strtotime to date php 
Php :: get key of array element php 
Php :: array key value php 
Php :: array_column in php 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =