I feel like an amateur for asking this, but I've been struggling at this for a long time and can't solve the problem.
I'm making a forum with embedded YouTube videos and a rich text editor. I need a function to convert the HTML tag to BBCode, another to convert the BBCode back to HTML.
BBCode to HTML
$message = (get message from database);
$A = '/\[youtube](.*?)\[\/youtube\]/is';
$B = '<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" width="425" height="350"><param name="movie" value="http://www.youtube.com/v/$1"><param name="wmode" value="transparent"></object>';
preg_replace($A, $B, $message);
I need a script that reverses this process, turning the HTML into BBCode. If someone could help me out I would be extremely grateful, or maybe suggest a easier method if one exists, or even a link that could provide some insight into the issue.
Thank you.