Re: removing lines from array

From: Date: Mon, 23 Jul 2001 07:49:15 +0000
Subject: Re: removing lines from array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-59133@lists.php.net to get a copy of this message
$recordsarray = file("records"); $remove = "schopf.net"; $temp = array(); for ($i=0;$i<count($recordsarray);$i++) { if (!strstr($recordsarray[$i], $remove)) { $temp[] = $recordsarray[$i]; } } $recordsarray = $temp; $lines = join($recordsarray, '\n'); $fp = fopen("records", "w"); fwrite($fp, $lines, strlen($lines)); fclose($fp); . . //should work //elias "Richard Kurth" <rkurth@pacifier.com> wrote in message news:13859124237.20010722163546@pacifier.com... > > I an trying to figure out how to remove lines from a text file from > within an array. > > I fill the array with this > $recordsarray = file ("../auto/records"); > > The lines I what to remove have this in them > $remove = "schopf.net "; > > What I need is how to loop through this array and pull out the lines > that have what is in the $remove variable. > > Then I will write the array to a temp file and thin copy it back to > the records file > > > This is a small sample of the file I what two remove lines from > mx - schopf.net High www.schopf.net > ptr - readinggenius.tv 207.200.75.55 24 > a - time-management-by-higher-productivity.com 207.252.75.55 24 > ptr www speedreading123.com 207.200.75.55 24 > ptr - mindbodyspirit123.com 207.200.75.247 24 > a www schopf.net 207.252.75.242 24 > soa - schopf.net dns1.northwesthost.com:dns2.northwesthost.com:rkurth@www.northwesthost.com:1 0800:3600:604800:86400 - > > > > > > > > > > > > Best regards, > Richard > mailto:rkurth@pacifier.com >

« previous php.general (#59133) next »