-
- $con = array(array("newtitle","newcontent"),array("newtitle2","newcontent2"));
- foreach($con as $id=>$ val)
- {
- $title = $val[0];
- $content = $val[1];
- $path = $id.'.htm';
- $fp = fopen("jia.htm", "r "); //Open the file in read-only mode
- $str = fread($fp, filesize("jia.htm")); //Read the file
- $str = str_replace("{title}", $title, $str); //Replace the content in the string
- $str = str_replace("{content}", $content, $str);
- fclose($fp); //Close the file
-
- $fpw = fopen ($path, "w"); //Open the file for writing
- fwrite($fpw, $str); //Write $str to the file
- fclose($fpw);
- echo "generate successfully!" ;
- }
- ?>
Copy code
|