Re: [PHP] Editing files by line

2002-07-11 Thread Chris Earle
Cool thanks, that probably will make my code execute a decent bit faster (as the file gets larger). But the array_search function never works for me (don't know why, I know exactly what I'm searching for and that it is there), so I made my own function.. //Find and return first occurance of a st

Re: [PHP] Editing files by line

2002-07-10 Thread Analysis & Solutions
On Thu, Jul 11, 2002 at 02:11:30PM +1000, Martin Towell wrote: >> From: Chris Earle [mailto:[EMAIL PROTECTED]] >> >> I was wondering if there was a function that would allow me to "jump" >> to a certain line if a file and then write from there? I'm searching >> php.net without any luck :(. > >

Re: [PHP] Editing files by line

2002-07-10 Thread Chris Earle
That's what I was talking about :). I wish there was something built in that would just let me append a file where I want, that would make things a little easier. Oh well, thanks a lot for the help that makes sense (and I think it works). "Martin Towell" <[EMAIL PROTECTED]> wrote in message 641

RE: [PHP] Editing files by line

2002-07-10 Thread Martin Towell
I dodn't know of any single function that does what you want, but you can do this: $contents = file($filename); // each line has it's own array position $contents[$line] = $newline; $content = implode("\n", $contents); $f = fopen($filename, "w"); fputs($f, $content); fclose($f); (not tested, b