Home > Backend Development > PHP Tutorial > 如何进行向上取整,以500递增

如何进行向上取整,以500递增

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:38:08
Original
1133 people have browsed it

条件:
以500递进,
规则:如现在是4200,则自动使其变成4500;如现在是4700,则变成5000;4500或者5000这种不变,请支招


回复讨论(解决方案)

$d = array(4200, 4700, 5000, 4500);foreach($d as $v) {  printf("%d : %d\n", $v, ceil($v/500)*500);}
Copy after login
4200 : 45004700 : 50005000 : 50004500 : 4500
Copy after login

$vl=4500;$vl=((int)($vl/500))*500+($vl%500==0?0:500);echo $vl;
Copy after login

echo (floor($a / 500) * 500) + ( ($a % 500) ? 500 : 0 );

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template