Home  >  Article  >  Backend Development  >  How to use remainder and remainder in PHP

How to use remainder and remainder in PHP

不言
不言Original
2018-06-12 17:45:353076browse

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 &#39;<li>&#39;;}
  ?>
 <span><?php echo $key.":". $value;?></span>
 
<?php
 if($key%2==0){echo &#39;</li>&#39;;}
};
 ?>

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 &#39;<li>&#39;;}
  ?>
 <span class="<?php echo($key%3); ?>span"><?php echo $key.":". $value;?></span>
 
<?php
 if($key%3==2){echo &#39;</li>&#39;;}
};
 ?>

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!

Statement:
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