我的博客主页通过循环浏览所有不同的博客类别并显示它们来工作
唯一的问题是我不希望显示某些博客分类
如何以某个数字结束循环?
这是代码:
提前致谢!
<?php $category=$news_article_category->listCategory();
foreach($category as $ids=>$name){ ?>
<?php if($ids==1)
{?>
<h3 class="open"><?php echo h($name); ?></h3>
<?php }else{ ?>
<h3><?php echo h($name); ?></h3>
<?php }?>
<div>
<?php $articles = $news_article->listlatestArticleByCat($ids);
?>
<?php foreach($articles as $id => $title);
$newVariable = str_replace(" ", "_", $title); ?>
<h2><a style="text-decoration:none; color:#333;" href="view_article.php?id=<?php echo h($newVariable); ?>"><?php echo h($title); ?></a></h2>
<p><?php $article = $news_article->getFromId($id);?>
<?php $string = strip_tags($article['NewsArticle']['content'], '<p><br><strong><em><span><a>');
$stringy=substr($string,0,350);
/*pos varaiable defines the position of last occurance of Space in the string of 300 characters*/
$pos=strripos($stringy," ");?>
<?php /*Substring the string eliminating the last incomplete words*/
echo substr($stringy,0,$pos); ?>
<?php if($name=='Wills and Probate'){?>
<a href="WillsProbate.php"> <img src="image/more_arrow.png" alt="" border="none"></a>
<?php }elseif($name=='Landlord and Tenant') {?>
<a href="LandlordTenant.php"> <img src="image/more_arrow.png" alt="" border="none"></a>
<?php }elseif($name=='Divorce and Family') {?>
<a href="DivorceFamily.php"> <img src="image/more_arrow.png" alt="" border="none"></a>
<?php }elseif($name=='Commercial Property') {?>
<a href="CommercialProperty.php"> <img src="image/more_arrow.png" alt="" border="none"></a>
<?php }elseif($name=='Lease Extensions') {?>
<a href="LeaseExtension.php"> <img src="image/more_arrow.png" alt="" border="none"></a>
<?php }elseif($name=='Conveyancing') {?>
<a href="conveyancing.php"> <img src="image/more_arrow.png" alt="" border="none"></a>
<?php } ?>
</p>