strings
| From: | Anthony Ritter | Date: | Fri, 01 Aug 2003 23:56:48 +0000 |
| Subject: | strings | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-158020@lists.php.net to get a copy of this message | ||
In the following snippet, I'm trying to open and read a URL into the
variable $contents.
I'd like to use preg_replace() to return only part of that string beginning
with say - regional and ending with new - but I get the complete URL string
returned.
Thank you for any assistance.
Tony Ritter
...............................
<?
$theurl="http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt";
if (!($fp=fopen($theurl, "r")))
{
echo "Could not open the URL.";
exit;
}
$contents=fread($fp, 1000000);
$newtext= preg_replace("/.*?(regional.*new).*/","1",$contents);
fclose($fp);
echo $newtext;
?>