sspoke Posted December 1, 2010 Share Posted December 1, 2010 How am i to do this either a php builtin function i am unaware about or something simple with regular expressions replacing I need a way to remove whitespace (tabs,spaces,newlines,etc) and anything else that seperates <> tags such as <td class="subject solvedbg"> <div> <span id="msg_1">blah blah space see <a href="blahblah> </div> </td> to <td class="subject solvedbg"><div><span id="msg_1">blah blah space see<a href="blahblah></div></td> Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/220372-trim-whitespace-from-left-and-right-of-html-tags/ Share on other sites More sharing options...
Rifts Posted December 1, 2010 Share Posted December 1, 2010 http://www.websiteoptimization.com/speed/tweak/whitespace/ Quote Link to comment https://forums.phpfreaks.com/topic/220372-trim-whitespace-from-left-and-right-of-html-tags/#findComment-1141932 Share on other sites More sharing options...
AbraCadaver Posted December 1, 2010 Share Posted December 1, 2010 Several ways, here's one: $new = preg_replace('/[\s]+(<)|(>)[\s]+/', '$2$1', $old); Quote Link to comment https://forums.phpfreaks.com/topic/220372-trim-whitespace-from-left-and-right-of-html-tags/#findComment-1141983 Share on other sites More sharing options...
sspoke Posted December 2, 2010 Author Share Posted December 2, 2010 nice one abra and also thanks rifts good read Quote Link to comment https://forums.phpfreaks.com/topic/220372-trim-whitespace-from-left-and-right-of-html-tags/#findComment-1142033 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.