php生成html

View Code
 1 <?php
 2 //我是初学者
 3 $row=array(array('新闻标题','新闻内容'),array('新闻标题2','新闻内容2'),array('新闻标题3','新闻内容3'));
 4 foreach($row as $id=>$val){
 5     $title=$val[0];
 6     $content=$val[1];
 7     $path="a/$id.html";
 8     $fp=fopen("tmp.htm","r");
 9     $str=fread($fp,filesize("tmp.htm"));
10     $str=str_replace("{title}","$title",$str);
11     $str=str_replace("{content}","$content",$str);
12     fclose($fp);
13     $handle=fopen("$path","w");
14     fwrite($handle,"$str");
15     echo"生成成功<br>";
16 
17 
18 
19 }
20 ?>
posted @ 2012-10-08 14:40  andywonglxy  阅读(57)  评论(0)    收藏  举报