I have a PHP file with a mix of html, text and php includes name areaname-house.php. The text/html parts of the file contain the String "areaname" in various places. On the other hand I have an array of Strings with city names.
I need a PHP script which can take each string (from strings array), copy the areaname-house.php and create a new file named arrayitem-house.php and then in the newly created file, replace the string "areaname" with the arrayitem. I have been able to do the first part where I can successfully create a clone file using a sample variable (city name) as a test in the following code :
<?php
$cityname = "acton";
$newfile = $cityname . "-house.php";
$file = "areaname-house.php";
if (!copy($file, $newfile)) {
echo "failed to copy $file...n";
}else{
// open the $newfile and replace the string areaname with $cityname
}
?>