开发者

PHP: Only showing 1 match when 2 exists

I have this:

$content = htmlspecialchars($show["status"]);
if (preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+#", $content, $matches)) {
  foreach(arr开发者_C百科ay_unique($matches) as $m) {
?><a id="<?php echo $m; ?>" data-id="<?php echo $id; ?>" class="fancybox_vid"><img src="images/icons/youtube.png" style="margin-right: 4px;"></a><?php
  }
}
echo $content;

Right now if there exists 2 links in $content, it will only make 1 anchor+imageicon, but I want it to then make two anchor+imageicon? What is wrong and how can i fix this?

I tried remove the array_unique, made no difference.


Try using preg_match_all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜