How to use remainder and remainder in PHP

不言
Release: 2023-03-31 20:38:02
Original
3120 people have browsed it

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;;}
};
 ?>
Copy after login

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;;}
};
 ?>
Copy after login

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!

Related labels:
source:php.cn
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