Re: strings
| From: | Anthony Ritter | Date: | Sat, 02 Aug 2003 01:43:13 +0000 |
| Subject: | Re: strings | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158028@lists.php.net to get a copy of this message | ||
Curt Zirzow wrote in message:
> This exact thing was talked about earlier today, with the subject
> 'Using eregi_replace()'.
........................
Right.
However, I've tried using the following code in which the text from the URL
is printed out completely and then I change the variable from $contents to
$text and using the line with preg_replace(), it still outputs the complete
text without the pattern match.
Any advice will be helpful.
Thank you.
TR
............................
<?
$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);
fclose($fp);
echo $contents;
echo "<br>";
$text=$contents;
$newtext= preg_replace("!.*?(REGIONAL.*YORK).*!","$1",$text);
echo $newtext; // outputs the same text as above
?>
..............................