当前位置:首页 > PHP教程 > php应用 > 列表

php怎么运行余数 PHP中余数、取余的妙用

发布:smiling 来源: PHP粉丝网  添加日期:2018-07-03 14:30:36 浏览: 评论:0 
  1. <?php<p>  </p><p>$ary=array("name","egineer","sonny","tonny","pingk","apple","phone","clone","pink","colle");</p><p>foreach($aryas$key=>$value){</p><p>$key=$key+1;</p><p>if($key%2==1){echo'<li>';}</p><p>  ?></p><p> <span><?phpecho$key.":".$value;?></span></p><p>  </p><p><?php</p><p> if($key%2==0){echo'</li>';}</p><p>};</p><p> ?></p> 
  2.    
  3. $ary=array("name","egineer","sonny","tonny","pingk","apple","phone","clone","pink","colle"); 
  4. foreach($aryas$key=>$value){ 
  5. $key=$key+1; 
  6. if($key%2==1){echo'<li>';} 
  7.   ?> 
  8.  <span><?phpecho$key.":".$value;?></span> 
  9.  //phpfensi.com 
  10. <?php 
  11.  if($key%2==0){echo'</li>';} 
  12. }; 
  13.  ?> 

second_one

  1. <?php 
  2.    
  3. $ary=array("name","egineer","sonny","tonny","pingk","apple","phone","clone","pink","colle"); 
  4. foreach($aryas$key=>$value){ 
  5. $key=$key
  6. if($key%3==0){echo'<li>';} 
  7.   ?> 
  8.  <spanclass="<?php echo($key%3); ?>span"><?phpecho$key.":".$value;?></span> 
  9.    
  10. <?php 
  11.  if($key%3==2){echo'</li>';} 
  12. }; 
  13.  ?> 

Tags: 余数 妙用

分享到:

相关文章