Quantcast
Channel: User user3040610 - Stack Overflow
Viewing all articles
Browse latest Browse all 44

Answer by user3040610 for How to replace specific tag with regex in php?

$
0
0
Try this to replace the anchor text to given string with preg_replace,$string = 'dog';$content = 'a quick brown <a href="some-link"> fox</a> jumps over a lazy <a href="another-link"> dog</a>';echo preg_replace('/<a(.+?)>.+?<\/a>/i',"<a$1>".$string."</a>",$content);

Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>