Re: how to delete some lines in a file
| From: | Jason Bryner | Date: | Thu, 13 Jul 2000 23:14:28 +0000 |
| Subject: | Re: how to delete some lines in a file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6563@lists.php.net to get a copy of this message | ||
on 7/13/00 1:17 PM, xinkun wang at xinkun_wang@hotmail.com wrote:
> if I want to delete some lines in a file, I must fopen it and save it in an
> array, but I can't delete elements in the array due to lacking of such
> function, any ideas?
> if I make it like for ($i=0;i<10;i++)
> $array[$i]="new";
> and write it to the file, the result is file wirte "new"s in one line, not
> in 10 line saperately. I don't know why.
>
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at
> http://www.hotmail.com
>
You need to add a "\n" after "new". That'll escape a newline. To remove a
line, there's a function that reads a file into an array. Each array
element is a line in the file. Then you can make a loop to read through the
array and at a certain line number ( array[line number] ) replace the value
with "".
Hope that helps. Sorry I can't give you exact code, I have it somewhere
cause I just used it in my current project, but my brain is fried right now.
Jason Bryner
--
Focus Design
http://www.focusdesigngroup.com