Hi,
I need to replace the anchor tag with text
Example:
<a href=aaa.php>aaa</a> should be replaced as ccc
any help is appreciated.
| SitePoint Sponsor |
Hi,
I need to replace the anchor tag with text
Example:
<a href=aaa.php>aaa</a> should be replaced as ccc
any help is appreciated.
Why ccc? From where is "ccc"??? you can use str_replace for your problem, like this str_replace('<a href="aaa.php">aaa</a>', 'ccc', $yourHTMLString);
ccc is just an example.
all anchor tags should be replaced by a text.
The anchor tags have different href values.
result:PHP Code:preg_replace('/<a[^>]*>.*?<\/a>/', 'ccc', 'Let us see if <a href="whatever">whatever</a> this regex gets all the <a>anchor tags</a> ?');
I used this tutorial to put the regex together, and this regex tester to test it (there are lots of them, I found this one googling for 'preg_replace tester').Code:"Let's see if ccc this regex gets all the ccc ?"
Guido - Community Team Advisor
Do you know where the (database) error is? Add it to the list!
Thinking Web: Voices of the Community
Blog - Free Flash Slideshow Widget
This code works...Thank you...
Bookmarks