Re[2]: [PHP] remove a line from a text list

From: Date: Wed, 05 Mar 2003 21:06:02 +0000
Subject: Re[2]: [PHP] remove a line from a text list
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-138361@lists.php.net to get a copy of this message
Hello Jason, Wednesday, March 5, 2003, 12:38:39 PM, you wrote: JW> On Thursday 06 March 2003 04:18, Richard Kurth wrote: >> This script will remove a line from a text list of email address and >> then re-write the list. The only problem I am having is when it >> re-writes the list it adds a extra line between each record. How can I >> stop this from happening >> >> $recordsarray = file($members); >> $remove = "rdkurth@northwesthost.com"; >> $temp = array(); >> for ($i=0;$i<count($recordsarray);$i++) >> { >> if (!strstr($recordsarray[$i], $remove)) >> { >> $temp[] = $recordsarray[$i]; >> } >> } >> $recordsarray = $temp; >> $lines = implode($recordsarray,''); >> $fp = fopen($members, "w"); >> fwrite($fp, $lines, strlen($lines)); >> fclose($fp); >> >> This is what the list looks like befor >> rdkurth@directphp.net|Mr.|Richard|Kurth|1046848049|03/04/2003 >> rdkurth@directphp.com|Mr.|Richard|Kurth|1046854222|03/05/2003 >> rdkurth@northwesthost.com|Mr.|Richard|Kurth|1046848049|03/04/2003 >> >> This is what it looks like after I remove a line >> rdkurth@directphp.net|Mr.|Richard|Kurth|1046848049|03/04/2003 >> >> rdkurth@directphp.com|Mr.|Richard|Kurth|1046854222|03/05/2003 JW> I tried your code and it works fine for me :-) It didn't add a extra lines in between the lines in the list. Because it does it every time for me. I guess it does not mater I just wanted it to keep the list nice and tight and together. -- Best regards, Richard mailto:rdkurth@starband.net

« previous php.general (#138361) next »