I’ve found dozens of functions that can remove whole HTML tags with the preg_replace() function, but I need to remove only the html brackets < and > (leaving anything inside them put). What regexp would accomplish this?
I’ve found dozens of functions that can remove whole HTML tags with the preg_replace()
Share
How about
htmlspecialchars. It replaces HTML reserved characters with escape sequences. This way the characters are displayed in the browser but aren’t harmful at all.This probably is what you want – show exactly the text the client typed in, but make it harmless.
PS: If you really do need a regex to remove tag-brackets, here you go:
$text = preg_replace('/[<>]/', '', $text).