Rumah >pembangunan bahagian belakang >tutorial php >PHP中余数、取余的妙用,php余数妙用_PHP教程

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

WBOY
WBOYasal
2016-07-13 09:48:181083semak imbas

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=$...
Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn