I need to remove only the specific tag </licenses> from an XML file saved to a variable.
I've tried this, but I'm not getting the expected output:
<?php
print preg_replace("</licenses>", "", "</licenses>");
?>
Returns:
<>
And surprisingly, the following removes the contents of all tags:
<?php
print preg_replace("<>", "", "</licenses>");
?>
All I can think is that I'm somehow hitting a regex pattern or something. How can I do this?
<and>are used as the delimiters. Only what is inside them, "/licenses", will be replaced.