将 YouTube 嵌入代码精简为仅 URL
请帮忙!
我需要删除以下代码,以便它只使用“值”部分
$<object width="360" height="226"><param name="movie" value="http://www.youtube.com/v/IkZuQ-aTIs0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/IkZuQ-aTIs0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="360" height="226"></embed></object>
所以在这种情况下,它将把它删除为 http://www.youtube.com/v/IkZuQ-aTIs0
问题是这是动态的,因此它会为不同的文件提取这些嵌入代码,因此它们会发生变化。
请帮忙:D
Please help!
I need to strip the following code so that it only uses the "value" part
lt;object width="360" height="226"><param name="movie" value="http://www.youtube.com/v/IkZuQ-aTIs0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/IkZuQ-aTIs0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="360" height="226"></embed></object>
So in this case it would strip it down to http://www.youtube.com/v/IkZuQ-aTIs0
The catch is that this is dynamic so it is pulling these embed codes for different files so they are changing.
Please help :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最好的方法是使用 DOM 解析器。
http://php.net/manual/en/class.domdocument.php
The best way is to use a DOM parser.
http://php.net/manual/en/class.domdocument.php
比 webartos 复杂一点,但会获取任何价值,而不仅仅是 YouTube 链接
little more complex than webartos, but will grab any value, instead of just the youtube link