lostprophetpunk Posted August 19, 2008 Share Posted August 19, 2008 I am working on an edit script for my article system, however I have come across a problem. This code is for my posting script so that the bbcode is converted to html... function bbcode_format ($posted) { $posted = htmlentities($posted); $simple_search = array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[url\=(.*?)\](.*?)\[\/url\]/is', '/\[n]/is', '/\[img\=(.*?)\](.*?)\[\/img\]/is' ); $simple_replace = array( '<b>$1</b>', '<i>$1</i>', '<u>$1</u>', '<a href="$1" target="_blank">$2</a>', '<br />', '<img src="$1" alt="$2" />' ); // Do simple BBCode's $posted = preg_replace ($simple_search, $simple_replace, $posted); return $posted; }; I would like to make it so that the function converts the html into the bbcode so that it can be edited. Link to comment https://forums.phpfreaks.com/topic/120374-preg_replace-switch-around/ Share on other sites More sharing options...
lostprophetpunk Posted August 20, 2008 Author Share Posted August 20, 2008 Isn't there anyone that can help? I mean this by converting the html code that was converted by using the function in the code above, and converting that into the bbcode that was originally converted. Link to comment https://forums.phpfreaks.com/topic/120374-preg_replace-switch-around/#findComment-620857 Share on other sites More sharing options...
MasterACE14 Posted August 20, 2008 Share Posted August 20, 2008 I'm assuming this is being used for a forum or messaging system. You would not need a function to convert it. You would grab whatever was posted or messaged using $_POST['message'] and you can use it how it is. Before using the BB code function. Link to comment https://forums.phpfreaks.com/topic/120374-preg_replace-switch-around/#findComment-620861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.