Re: [PHP] Append to the beginning of a file...

2002-03-22 Thread Chris Hewitt
Mauricio, If you are on a *nix computer, you could append to the end of the file, close it and then do a "tail -n1" which will give you just the last line in the file. HTH. Regards Chris Mauricio Sthandier wrote: >I guess I should do that. >I need the plain file because is just a log of use

Re: [PHP] Append to the beginning of a file...

2002-03-21 Thread Mauricio Sthandier
Well, here's a lousy solution to a lousy problem : (please don't crucify my code since I know it's not depurated) --- $archivo = fopen("./registrados.txt", "a+"); if ($archivo) { $posicion = fseek($archivo, -512, SE

Re: [PHP] Append to the beginning of a file...

2002-03-21 Thread Miguel Cruz
On Thu, 21 Mar 2002, Mauricio Sthandier wrote: > I could append but then I need to read the first 8 chars of the last line I > appended... neither something I know how to do. Seek to the end of the file minus typical record length, read, look for the penultimate end-of-record delimiter (\n, prob

Re: [PHP] Append to the beginning of a file...

2002-03-21 Thread Mauricio Sthandier
I guess I should do that. I need the plain file because is just a log of users registering in a Club, in a csv format. Using a database is just too much and not intended for this page... even when I would prefer using mysql. At least, I can handle that rather than the fopen and fwrite !. I could a

Re: [PHP] Append to the beginning of a file...

2002-03-21 Thread Jason Wong
On Friday 22 March 2002 00:40, Mauricio Sthandier wrote: > I already seen it... I used "r+" and "aw". > I saw and example in www.php.net, in the fopen function description, but it > is incomplete... > this is taking me hours !!!. > Well, if I can preappend... how can I read, for example, the first

Re: [PHP] Append to the beginning of a file...

2002-03-21 Thread Miguel Cruz
On Thu, 21 Mar 2002, Mauricio Sthandier wrote: > I guess thist must be really silly... but how can I append text to the > beginning of a file ??? > I've been trying since a while... but all I get is overwriting !. Open a temporary file, write your new data to it, copy the old file on to the end

Re: [PHP] Append to the beginning of a file...

2002-03-21 Thread Mauricio Sthandier
I already seen it... I used "r+" and "aw". I saw and example in www.php.net, in the fopen function description, but it is incomplete... this is taking me hours !!!. Well, if I can preappend... how can I read, for example, the first 8 chars of the last line I inserted ?. They have no fixed length.

[PHP] Append to the beginning of a file...

2002-03-21 Thread Mauricio Sthandier
I guess thist must be really silly... but how can I append text to the beginning of a file ??? I've been trying since a while... but all I get is overwriting !. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php