开发者

PHP: Only showing 1 match when 2 exists

开发者 https://www.devze.com 2023-01-31 10:50 出处:网络
I have this: $content = htmlspecialchars($show[\"status\"]); if (preg_match(\"#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\\n]+|(?<=v=)[^&\\n]+#\", $content, $matches)) {

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

精彩评论

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