首页 > 解决方案 > 我用这个 preg_replace 代码嵌入视频做错了什么?

问题描述

我正在尝试直接从链接嵌入视频

链接示例

https://www.example.com/video22818393/dancing_with_the_moon

标准嵌入代码:

<iframe src="https://www.example.com/embedframe/22818393" frameborder=0 width=510 height=400 scrolling=no allowfullscreen=allowfullscreen></iframe>

我的代码直接从链接嵌入视频:

$post[message] = preg_replace('/<a href="https?:\/\/www\.example\.com\/video([a-z0-9A-Z]+)\/([a-z0-9A-Z]+)" target="_blank">(.+?)<\/a>/', '<iframe src="https://www.example.com/embedframe/$1" frameborder=0 width=510 height=400 scrolling=no allowfullscreen=allowfullscreen></iframe>', $post[message]);

但是这段代码只显示站点链接而不是视频,所以有人知道我做错了什么吗?

标签: phpiframepreg-replaceembed

解决方案


推荐阅读