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.
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.
preg_replace('/<a[^>]*>.*?<\\/a>/', 'ccc', 'Let us see if <a href="whatever">whatever</a> this regex gets all the <a>anchor tags</a> ?');
result:
"Let's see if ccc this regex gets all the ccc ?"
I used this tutorial to put the regex together, and this [URL=“http://www.spaweditor.com/scripts/regex/index.php”]regex tester to test it (there are lots of them, I found this one googling for ‘preg_replace tester’).
This code works…Thank you…