專業南寧網站建設10年,服務客戶1000+

PHP,KINGCMS中余數、取余的妙用

2019-04-03


PHP,KINGCMS中余數、取余的妙用

<?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>';}
  ?>
 <span><?php echo $key.":". $value;?></span>
  
<?php
 if($key%2==0){echo '</li>';}
};
 ?>


匹配效果:


<ul>

<li><div>aaa</div><div>bbb</div></li>

<li><div>aaa</div><div>bbb</div></li>

<li><div>aaa</div><div>bbb</div></li>

</ul>



  在kingcms寫法:

{king:portal.ad listid='96' number='100'}         
<?php if ({king:i/}%2 == 1) {echo "<li>";} ?>
<div><a href="{king:_adurl/}" title="{king:title/}{king:i/}"><img src="{config:system.inst/}{king:image/}" alt="{king:title/}" /></a></div>
<?php if ({king:i/}%2 == 0) {echo "</li>";} ?>
{/king:portal.ad}

0
首頁
案例
關于
聯系
街机麻将玩法