当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Value Counter / Calculator

问题描述:

I would like to achieve the following: I have a variable A with a value from 1 - 1000. For every 100 the value reaches, a second variable B should get added +1. A third variable C should echo all number of variable A which are less than 100

For example:

$a = 10

$b = 0

$c = 10

$a = 100

$b = 1

$c = 00

$a = 110

$b = 1

$c = 10

$a = 1530

$b = 15

$c = 30

What's the best way to achieve that in PHP? Use str_split() oder count()?

网友答案:
$b = floor($a/100);
$c = $a % 100;
echo 'wow, that was easy';
分享给朋友:
您可能感兴趣的文章:
随机阅读: