Re: ereg()

From: Date: Tue, 28 Aug 2001 08:08:59 +0000
Subject: Re: ereg()
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-64743@lists.php.net to get a copy of this message
You could try fgets from the fp instead of fread. Then for each line depending on how well structured it is you have a variety of options, but i think this would be at least a good start: www.php.net/preg_split - split on multiple spaces - \s+ jack Ben Quinn wrote: > Hi all > > Say i had text similar to below > > Cairns Fine > Mareeba Fine > Innisfail Fine > > I'm using the following code to grab the weather forecast for each of those > towns > > $GrabURL = "forecast_map_data.txt"; > $GrabStart = "PROVINCIAL CITY"; > $GrabEnd = "UV ratings"; > > $file = fopen("$GrabURL", "r"); > $rf = fread($file, 20000); > $grab = eregi("$GrabStart(.*)$GrabEnd", $rf, $show); > > eregi("Cairns(.*)Mareeba", $show[1], $cairns); > > which works fine, but when i then try to grab the forecast for Mareeba using > this > > eregi("Mareeba(.*)Innisfail", $show[1], $mareeba); > > nothing happens - i figure it's because i've already use Mareeba as a stop > point. Can anyone recommend a function or a way to do this where i'll be > able to use the same start or stop text more than once? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net Ben Quinn wrote: > Hi all > > Say i had text similar to below > > Cairns Fine > Mareeba Fine > Innisfail Fine > > I'm using the following code to grab the weather forecast for each of those > towns > > $GrabURL = "forecast_map_data.txt"; > $GrabStart = "PROVINCIAL CITY"; > $GrabEnd = "UV ratings"; > > $file = fopen("$GrabURL", "r"); > $rf = fread($file, 20000); > $grab = eregi("$GrabStart(.*)$GrabEnd", $rf, $show); > > eregi("Cairns(.*)Mareeba", $show[1], $cairns); > > which works fine, but when i then try to grab the forecast for Mareeba using > this > > eregi("Mareeba(.*)Innisfail", $show[1], $mareeba); > > nothing happens - i figure it's because i've already use Mareeba as a stop > point. Can anyone recommend a function or a way to do this where i'll be > able to use the same start or stop text more than once? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#64743) next »