0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【PHP】余り計算の活用方法

Last updated at Posted at 2021-09-06
<?php

$cnt = 3;

3 % 3 余りは0

2 % 3 余りは2 

1 % 3 余りは1  

0 % 3 余りは0

$nocori = $cnt - (1 % 3);
//残りは2となる
?>


4 % 4 余りは0

3 % 4 余りは3

2 % 4 余りは2 

1 % 4 余りは1  

0 % 4 余りは0

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?