function stripEmptyTags ($result)
{
$regexps = array (
'~<(\w+)\b[^\>]*>\s*\\1>~',
'~<\w+\s*/>~'
);
do
{
$string = $result;
$result = preg_replace ($regexps, '', $string);
}
while ($result != $string);
return $result;
}
$string = "text
";
echo stripEmptyTags ($string);