Re: Editing Files: Help!
- From: Rik <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Tue, 31 Jul 2007 03:38:26 +0200
On Tue, 31 Jul 2007 03:20:48 +0200, ttrium <arcotik@xxxxxxxxx> wrote:
On Jul 30, 8:15 pm, Rik <luiheidsgoe...@xxxxxxxxxxx> wrote:On Tue, 31 Jul 2007 03:10:10 +0200, ttrium <arco...@xxxxxxxxx> wrote:
> Ok, so this is probably the easist question ever posted, but I
> honestly can't find the answer (if there is one).
> How do I (by which function) add data to a file at the beginning of a
> file, rather than the end of the file (as is with fopen(file, "a"))?
You cannot 'prepend' data. You'll have to fetch the content, write your
new content to the beginning of the file, and then add the old content.
Is there a simpler way by using databases?
If by this you mean: 'if I have the content in a database instead of a file', why yes indeed.
UPDATE table SET field = CONCAT('prepended string',field);
However, if the order of things in the field matter (I don't know what data we're talking about), maybe different rows is a better solution.
--
Rik Wasmus
.
- References:
- Editing Files: Help!
- From: ttrium
- Re: Editing Files: Help!
- From: Rik
- Re: Editing Files: Help!
- From: ttrium
- Editing Files: Help!
- Prev by Date: passing $_POST variables to classes
- Next by Date: Re: passing $_POST variables to classes
- Previous by thread: Re: Editing Files: Help!
- Next by thread: Re: Editing Files: Help!
- Index(es):