Hi there.
The code I'll post here is experimental, but I think I have the solution for you. Anyway please let me know.
<?php
if (preg_match("/<code>/",$text)) // I'm assuming $text as the text entered by the user
{
while(!(preg_match("/<\/code>",$text)))
{
preg_replace("/</","<",$text);
preg_replace("/>/",">",$text);
}
}
?>
Best regards,