Home >Backend Development >PHP Tutorial >The wonderful use of remainder and remainder in PHP, the wonderful use of remainder in php_PHP tutorial

The wonderful use of remainder and remainder in PHP, the wonderful use of remainder in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:48:181109browse

The wonderful use of remainder and remainder in PHP, the wonderful use of remainder in PHP

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

second_one

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

You can check the results and analyze the cleverness after running it~

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1024132.htmlTechArticleThe wonderful use of remainder and remainder in PHP, the wonderful use of remainder in php php $ary=array("name","egineer ","sonny","tonny","pingk","apple","phone","clone","pink","colle");foreach($ary as $key=$value){$key= $...
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