首页 >后端开发 >php教程 >PHP中余数、取余的妙用,php余数妙用_PHP教程

PHP中余数、取余的妙用,php余数妙用_PHP教程

WBOY
WBOY原创
2016-07-13 09:48:181082浏览

PHP中余数、取余的妙用,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;>

大家可以运行以后查看结果并分析其巧妙之处~

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1024132.htmlTechArticlePHP中余数、取余的妙用,php余数妙用 php $ary=array("name","egineer","sonny","tonny","pingk","apple","phone","clone","pink","colle");foreach($ary as $key=$value){$key=$...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn