Forum Moderators: coopster
Just so i'm clear what I want to do exactly is open a file that essentially has alot of variables stored in it like this.
$names = 'joe¦bob¦clem';
$phone = '3453232¦323232';
And it just goes on like that for a few hundred variables. Now all I want to do is open the file up find a certain variable and then just add the string I have to it. So like I have the new $names variable and it contains 'joe¦bob¦clem¦chris' and I just want to save that string to the file. I know it's possible but I usually work only with mySQL so I don't know how to open a file find where I want to edit, edit it and then save the file.
Thanks in advance for anyone who can point me in the right direction.
That should be really no problem! There are different solutions for your problem. file handling is a little bit similar to C - Code. e.g. You open the file with fopen() and the right parameters like r (read only) or r+ (read and write). The file pointer stands on the beginning of the file, than you have to place the pointer and write the string with fwrite() and then close the file with fclose().
All about this you kan read at:
[php.net...]
The more interesting on your problem is the search algorythm. There are really hundreds of different ways. In your case, I think you know about the structure of the file, it should be the easiest to read in the file into an array with file(). Then you jump into the right line and edit the array and then write the file new. Thats a very bad solution on performance but I think it should be easy to do.