我有内容变量$number['content']
,其中有占位符<!--email-->
,需要用$email
变量替换。
下面是存储在内容变量中的内容。
<iframe src="url.com&em=<!--email-->&se=51" style="width:900px;height:700px;"></iframe>
我需要用变量替换$email
我有内容变量$number['content']
,其中有占位符<!--email-->
,需要用$email
变量替换。
下面是存储在内容变量中的内容。
<iframe src="url.com&em=<!--email-->&se=51" style="width:900px;height:700px;"></iframe>
我需要用变量替换$email
这将取代应该工作。
<?php
$content = '<iframe src="url.com&em=<!--email-->&se=51" style="width:900px;height:700px;"></iframe>';
$content = str_replace('<!-- email -->', $email, $content);
如果可能的话,我会建议使用sprintf()。
<?php
$content = '<iframe src="url.com&em=%s&se=51" style="width:900px;height:700px;"></iframe>';
$content = sprintf($content, $email);