0

I think my the regex is off (not very good at regex yet). What I'm trying to do is remove the first and last <section> tags (though this is set to replace all, if it worked). I set it up like this so it would completely remove any attributes of the tag, along with the closing tag.

The code:

//Remove from string
$content = "<section><p>Test</p></section>";
$section = "<(.*?)section(.*?)>";
$output= str_replace($section, "", $content);
echo $output;
pilsetnieks
  • 10,330
  • 12
  • 48
  • 60
Casey Dwayne
  • 2,142
  • 1
  • 17
  • 32

1 Answers1

2

You are looking for strip_tags.

Try this:

print strip_tags($content, '<section>');
Sumoanand
  • 8,835
  • 2
  • 47
  • 46