I am using preg_replace to strip out <p> tags and <li> tags and making them carriage returns. I have some <a> tags in my string, and I want to strip those out, but keep the href attribute. For instance, if I have:
<a href = "http://www.example.com">Click Here</a>, what I want is: http://www.example.com Click Here
Here is what I have so far
$text .= preg_replace(array("/<p[^>]*>/iU","/<\/p[^>]*>/iU","/<ul[^>]*>/iU","/<\/ul[^>]*>/iU","/<li[^>]*>/iU","/<\/li[^>]*>/iU"), array("","\r\n\r\n","","\r\n\r\n","","\r\n"), $content);
Thanks
If I were you I would use SimpleHTMLDom. Here’s a usage example from the docs: