替换占位符和回声内容

时间:2012-08-01 02:21:49

标签: php

我的内容变量$number['content']中包含占位符<!--email-->,需要将其替换为$email变量。

以下是存储在内容变量中的内容。 <iframe src="url.com&em=<!--email-->&se=51" style="width:900px;height:700px;"></iframe>

我需要用变量$email

替换

1 个答案:

答案 0 :(得分:0)

这将取代应该工作。

<?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);