/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** * Find and close unclosed xml tags **/ function close_tags($text) { $patt_open = "%((?<!</)(?<=<)[\s]*[^/!>\s]+(?=>|[\s]+[^>]*[^/]>)(?!/>))%"; $patt_close = "%((?<=</)([^>]+)(?=>))%"; { $m_open = $matches[1]; { $m_close = $matches2[1]; { foreach ($m_close as $tag) $c_tags[$tag]++; foreach ($m_open as $k => $tag) if ($c_tags[$tag]--<=0) $text.='</'.$tag.'>'; } } } return $text; } ?>