This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!

Test remove empty HTML tags

By: Manhhailua on Jan 10th, 2014  |  syntax: PHP  |  size: 0.35 KB  |  views: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $demo = '<div><span><span><span></span></span></span></div><div><span></span>manhhailua</div>';
  2.  
  3. $oDOMHTML = DOMDocument::loadHTML(
  4.     $demo,
  5.     LIBXML_HTML_NOIMPLIED |
  6.     LIBXML_HTML_NODEFDTD |
  7.     LIBXML_NOBLANKS |
  8.     LIBXML_NOEMPTYTAG
  9. );
  10.  
  11. $sYourHTMLStringWithoutEmptyTags = $oDOMHTML->saveXML();
  12.  
  13. echo $sYourHTMLStringWithoutEmptyTags;
clone this paste RAW Paste Data