I have a configuration file that I use to store several variables and
would like to provide a web-based interface to update this form.  I'm
having some trouble replacing part of the file while leaving the rest of
it intact.

An example of the config file is:

$eventInfo[1][1] = "First Event Title";
$eventInfo[1][2] = 145;
$eventInfo[1][3] = 300;

$eventInfo[2][1] = "Second Event Title";
$eventInfo[2][2] = 50;
$eventInfo[2][3] = 1500;

What I can't figure out is how to selectively update certain lines,
while leaving all the other lines intact and without changing the
structure or order of the page. So, if I wanted to change
$eventInfo[1][2] to 150 and $eventInfo[2][3] to 2000, how can I do that
without mucking up the rest of the page?  I can update any one line by
using something like the following:

$fd = fopen($configFile, "r+"); //open the file and truncate it.
$newContents = eregi_replace("eventInfo\[1\]\[1\] =
\".*\";","eventInfo[1][1] = \"" . $form_eventTitle . "\";",$contents);
$newFile = fwrite($fd,$newContents);

but if I try to update more than one line, it causes the rest of my file
to get truncated or other weird things to happen.

Any help is appreciated.


PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to