Note Submitter: sly at noiretblanc dot org
----
One bug in LWC's strip_tags function:
You must add a U option in the preg_replace to have it work when stripping content :
$str = 'test : <tag>blah</tag> hello <tag>blah</tag>';
$b = strip_only($str, 'tag', true);
will return "test : " without the U option
and return "test : hello" with it.
function strip_only($str, $tags, $stripContent = false) {
$content = '';
if(!is_array($tags)) {
$tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
if(end($tags) == '') array_pop($tags);
}
if ($stripContent)
foreach($tags as $tag)
$str = preg_replace('#<'.$tag.'[^>]*>.+</'.$tag.'[^>]*>'.'#isU', '', $str);
else
foreach($tags as $tag)
$str = preg_replace('#'.'</?'.$tag.'[^>]*>'.'#is', '', $str);
return $str;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.