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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]