代码
<?
$moban =file_get_contents('m.html');for($i=0;$i<5;$i++)
{
$gewei=rand(1,99);
$shiwei=rand(100,999);
$htmlcontent = str_replace('{a}',"$gewei",$moban);
$htmlcontent=str_replace('{a1}',"$shiwei",$htmlcontent);
$htmlname="$i.html";
file_put_contents($htmlname,$htmlcontent);
echo "文件创建成功".$i.".html<br>";
}
?>
m.html模板里面内容为 {a} <br>{a}<br>{a1}
生成的东西是 1 1 222
我在生成的时候发现{a}的内容都是相同的,我要得到的效果是
生成的东西为 1 2 222
这里只是举一个例子。那位大牛解决一下,谢谢。
<?
$moban =file_get_contents('m.html');for($i=0;$i<5;$i++)
{
$gewei=rand(1,99);
$shiwei=rand(100,999);
$htmlcontent = str_replace('{a}',"$gewei",$moban);
$htmlcontent=str_replace('{a1}',"$shiwei",$htmlcontent);
$htmlname="$i.html";
file_put_contents($htmlname,$htmlcontent);
echo "文件创建成功".$i.".html<br>";
}
?>
m.html模板里面内容为 {a} <br>{a}<br>{a1}
生成的东西是 1 1 222
我在生成的时候发现{a}的内容都是相同的,我要得到的效果是
生成的东西为 1 2 222
这里只是举一个例子。那位大牛解决一下,谢谢。
ps 时间复杂度O(n^2)效率极其地下方法2 用{a}做关键词切成数组再组装
我想两段都试试。对于那个时间复杂度有点不太明白。