PHP中余数、取余的妙用_php技巧

WBOY
發布: 2016-05-16 20:12:32
原創
1797 人瀏覽過
<&#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
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板