Re: Rewrite <img> and <a> tags.
| From: | Curt Zirzow | Date: | Fri, 25 Jul 2003 23:36:12 +0000 |
| Subject: | Re: Rewrite <img> and <a> tags. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156960@lists.php.net to get a copy of this message | ||
* Thus wrote Simon Fredriksson (simon@lan2k.org):
>
> How can I easiest rewrite A and IMG tags? I'm fetching a page with
> fsockopen() and I need to rewrite these tags before sending it on to a user.
>
> My own theory is that it's made with Regular Expressions. I just don't
> know these myself.
The documentation for preg_match_all has an excelent pattern for
matching html tags:
preg_match_all ("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/", $html, $matches);
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."