I’m trying to setup a html form that will take a file from a zip archive and edit it (change a few variables value) on submit.
so here’s the process:
user inputs details into the html form
a copy of a zip archive with a cofig.php will be copied into a temp folder
config.php will be extracted from the zip
once config.php has been extracted, the config.php in the zip will be deleted (ready for replacement)
the config.php that gets extracted needs to be edited
contents of config.php:
<?
$varible1 = "data_from_html_form";
$varible2 = "data_from_html_form";
$varible3 = "some_value";
//etc etc....
?>
the file will then be saved and placed back into the temporary zip archive ready to be distributed to the user.
All i need to know is how to edit the config.php and the variables in it.
Open a file with
fopento read your file into an array of strings, process it as you need (add/modify/remove), than usefile_put_contentsto save it back to file.You can call
file_put_contentswith one-dimension array as second argument, but check if all newlines are still present in new file. If they are disappeared, useimplode("\n",$contents)instead of just$contents.