2012-01-05 89 views
0

我使用這個循環從文章中提取圖像,把它放在圖像庫..我想要 超越或忽略var $圖像,如果不包含圖像..換句話說,我不需要打印$圖像或離開blanck空間在畫廊..感謝您的幫助如何讓循環忽略循環空白值?

 <?php 
        $count = 0; 
      // loop through and display format 
      foreach($articles as $article): 
       // stripes the table by adding a class to every other row 
       $class = (($count % 2) ? " class='altrow'": ''); 

       $regex = '/src="(.*?)"/'; 
    preg_match_all($regex, $article['Article']['content'], $matches); 
    $matches = $matches[1]; 
    foreach($matches as &$match) 
    $match = substr($match, strrpos($match, '/') + 1); 
    $image =(implode($matches)); 
      ?> 

    <li> <?php 
    if(isset($image) && $image != ""){ 
    e($html->link($html->image(image ,array('height'=>'75px', 'width'=>'75px')),array('action' => 'view', $article['Article']['id']),array('escape' => false))); 
    }else{ 

/// What is supposed to put here /// 


    } 
    ?></li> 



      <?php endforeach; ?> 
+1

老兄,格式化的代碼。傷害眼睛。 – 2012-01-05 04:31:33

回答