1
你好,我想獲得以下所有的唯一匹配。我該怎麼做?有什麼方法可以只用preg_match_all獲得唯一的匹配嗎?
preg_match_all('#http://[\S]+(?:jpe?g|png|gif)#is', $content, $filtered);
$filtered = array_unique($filtered[0]);
foreach($filtered as $value){
${'varpics' . $i} .= '<img width="200px" height="200px" src="'.$value.'"><br>'; }
我仍然得到雙重比賽。
我推薦array_unique,它是更乾淨的方法。 – Christian 2011-04-03 23:07:13
您好,馬克。你能檢查我的更新代碼嗎?我仍然得到雙重結果 – EnexoOnoma 2011-04-03 23:07:15
@Punkis:查看更新。 – mpen 2011-04-03 23:18:27