How can i strip including this content
I know you can use strip tags to remove the tags, but i want everything in between gone as w
If you want to strip ALL tags and including content:
$yourString = 'Hello Planet Earth. This is some sample content!';
$regex = '/<[^>]*>[^<]*<[^>]*>/';
echo preg_replace($regex, '', $yourString);
#=> Hello Earth. This is some content!
HTML attributes can contain < or >. So, if your HTML gets too messy this method will not work and you'll need a DOM parser.
NODE EXPLANATION
--------------------------------------------------------------------------------
< '<'
--------------------------------------------------------------------------------
[^>]* any character except: '>' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
> '>'
--------------------------------------------------------------------------------
[^<]* any character except: '<' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
< '<'
--------------------------------------------------------------------------------
[^>]* any character except: '>' (0 or more times
(matching the most amount possible))
--------------------------------------------------------------------------------
> '>'