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

PHP中余数、取余的妙用_PHP

WBOY
发布: 2016-05-30 08:45:54
原创
1299 人浏览过

<&#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;>
登录后复制

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

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板