Re: RSS / eregi_replace()
| From: | Anthony Ritter | Date: | Wed, 04 Aug 2004 01:26:02 +0000 |
| Subject: | Re: RSS / eregi_replace() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192645@lists.php.net to get a copy of this message | ||
Justin Patrin <papercrane@gmail.com> wrote in message:
> Thanks, lots of good info here. It's nice to have all of the info at once.
>
> I don't know about eregs myself, but I'll try a preg solution:
>
> $new_text = preg_replace('!<link>(.*?)</link>!', '<a
> href="\1"
> target="_blank">\1</a>', $text);
........
Thank you.
I tried the following:
<?
$text="<link>http://www.nytimes.com/2004/08/03/national/03tape.html?
ex=1249272000&en=484f82ff258ab8c7&ei=5088&partner=rssnyt</link>";
$new_text = preg_replace('!<link>(.*?)</link>!', '<a
href="\1"
target="_blank">\1</a>', $text);
echo $new_text;
?>
The output in my browser is the URL with no link - and no target="_blank".
http://www.nytimes.com/2004/08/03/national/03tape.html?
ex=1249272000&en=484f82ff258ab8c7&ei=5088&partner=rssnyt
If you get a chance run the script through your server and see.
I'm on apache.
Any throughts?
Many thanks for your time.
TR