This article mainly introduces the wonderful functions of remainder and remainder in PHP. This is a frequently used trick in WEB development. Whether it is in HTML processing such as tables, ul, li or line breaks, it needs to be done every few days. It is especially useful when changing lines, adding end tags of ul or li every few lines, etc. Friends who need it can refer to
<?php $ary=array("name","egineer","sonny","tonny","pingk","apple","phone","clone","pink","colle"); foreach($ary as $key=>$value){ $key=$key+1; if($key%2==1){echo '<li>';} ?> <span><?php echo $key.":". $value;?></span> <?php if($key%2==0){echo '</li>';} }; ?>
second_one
<?php $ary=array("name","egineer","sonny","tonny","pingk","apple","phone","clone","pink","colle"); foreach($ary as $key=>$value){ $key=$key; if($key%3==0){echo '<li>';} ?> <span class="<?php echo($key%3); ?>span"><?php echo $key.":". $value;?></span> <?php if($key%3==2){echo '</li>';} }; ?>
You can check the results and analyze them after running The cleverness~
The above is the entire content of this article. I hope it will be helpful to everyone's learning. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
php to implement student management system
Summary of the use of variable functions in php
The above is the detailed content of How to use remainder and remainder in PHP. For more information, please follow other related articles on the PHP Chinese website!