如何使用 php 提取自定义标签的内容,并用 cuctom 标签中的数据替换有效标签



请问我如何使用自定义标签并将内容替换为有效的html标签。 [video]thelinktothevideo[/video]然后替换为有效的YouTube视频。感谢您的帮助。我正在使用 php

最直接的方法是使用正则表达式替换。

$output = preg_replace('![video](.*?)[/video]!i', '<iframe width="560" height="315" src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>', $input);
您需要根据需要

修改代码,因为您需要将链接转换为其嵌入链接。

最新更新