BillyBoB Posted April 7, 2008 Share Posted April 7, 2008 I'm need to remove the <a> tag from any text but leave all other tags. The <a> tag could include any possible attributes including those like id, class, or href. If you can help me that would be great or just point me in the right direction. I have been working on this for hours still nothing comes up. Quote Link to comment Share on other sites More sharing options...
Orio Posted April 7, 2008 Share Posted April 7, 2008 <?php $str = 'Some <b>Text </b><span><a href="1.html"> 11</a><A href="1.htm"> ewfwm</a></span> <u>Hello</u>'; $pattern = "/<a ?.*<\/a>/si"; $replacement = ""; echo preg_replace($pattern, $replacement, $str); ?> Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.