像:
$output = preg_replace(
"/http\:\/\/(.*)\?mid\=([0-9|a-z|A-Z]*)/ismU",
"<iframe src=\"http://professional.player.qbrick.com/player.aspx?mid=${2}\"></iframe>",
$output
);
这不起作用......
我想要的是替换文本中的任何网址,如
http://professional.player.qbrick.com/player.aspx?mid=asdas23234ASD
与
<iframe src="http://professional.player.qbrick.com/player.aspx?mid=asdas23234ASD"></iframe>
答案 0 :(得分:0)
您可以使用sprintf来构建字符串。
答案 1 :(得分:0)
怎么样:
$output = 'http://professional.player.qbrick.com/player.aspx?mid=asdas23234ASD';
$output = preg_replace(
"#(http://.*?\?mid=[0-9a-zA-Z]+)\b#ismU",
"<iframe src=\"$1\"></iframe>",
$output
);
echo $output,"\n";
<强>输出:强>
<iframe src="http://professional.player.qbrick.com/player.aspx?mid=asdas23234ASD"></iframe>