-1

我有内容变量$number['content'],其中有占位符<!--email--> ,需要用$email变量替换。

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

我需要用变量替换$email

4

1 回答 1

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);
于 2012-08-01T02:24:30.183 回答