I have a POST form, than when submitted uses both key and value to replace lines in a set of .ini files.
$reading = fopen('Original/file.ini', 'r');
$writing = fopen('file.ini', 'w');
while (!feof($reading)) {
$line = fgets($reading);
foreach ( $_POST as $key => $value )
{
if (stristr($line, $key.)) {
$line = " ".$key." = ".$value.";
";
}
}
fputs($writing, $line);
}
fclose($reading); fclose($writing);
Now this is working fine. However, now I need to edit several files, of which many contains the same key. Of course, the file name and path the said files are not the same, so I was wondering if there's any way to group the text inputs, so I can keep using my PHP solution?
As an example, say I have both "product1.ini" and "product2.ini", but both have a "productPrice =" line. Any suggestions?