meral Posted August 20, 2009 Share Posted August 20, 2009 I have one string also having html tags... <p>hello</p><b>bold</b><br /><p style="text-align:right">right align</p> i want find all html tags and add space before and after that tag... #<p>#hello#</p>##<b>#bold#</b>##<br />##<p style="text-align:right">#right align#</p># Consider # as white space I think it can be achive through Regular Expression and preg_match but how i dont know... please help .. atleast give some idea.. Link to comment https://forums.phpfreaks.com/topic/171149-find-html-tags-and-replace/ Share on other sites More sharing options...
nrg_alpha Posted August 20, 2009 Share Posted August 20, 2009 Example: $html = '<p>hello</p><b>bold</b><br /><p style="text-align:right">right align</p>'; $html = preg_replace('#<[^>]+>#', ' $0 ', $html); Link to comment https://forums.phpfreaks.com/topic/171149-find-html-tags-and-replace/#findComment-902615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.