php - Remove all Tags with inner Content -


i want remove tags inner content.

i'm using following function.

function strip_tags_content($text, $tags = '', $invert = false) {      preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags);     $tags = array_unique($tags[1]);      if (is_array($tags) , count($tags) > 0) {         if ($invert == false) {             return preg_replace('@<(?!(?:' . implode('|', $tags) . ')\b)(\w+)\b.*?>.*?</\1>@si', '', $text);         } else {             return preg_replace('@<(' . implode('|', $tags) . ')\b.*?>.*?</\1>@si', '', $text);         }     } elseif ($invert == false) {         return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text);     }     return $text; } 

but still getting following result.

<p><span style="color: rgb(38, 38, 38); font-family: arial, helvetica, sans-serif; fon... 

i want html tags removed.

p, span etc. wrong?

you can use th php's built-in function strip_tags .

$striped_string = strip_tags($your_html_string); 

note: can optionally make sure tags not stripped passing tags second parameter

take @ php docs


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -