Fw: [PHP] FORUM CODE

From: Date: Tue, 03 Sep 2002 21:53:43 +0000
Subject: Fw: [PHP] FORUM CODE
Groups: php.general 
Request: Send a blank email to php-general+get-115098@lists.php.net to get a copy of this message
str_replace(); http://www.php.net/manual/en/function.str-replace.php Here's an example how you might use str_replace() to create your own scripting syntax.. --- $myformtxt = '[i]Hello[/i] [B]world[/B]'; // pretend this came from a form. function parse_script($str) { // The array could be stored in a separate file for easy editing. $mysyntax = array ( '[i]' => '<i>', '[/i]' => '</i>', '[b]' => '<b>', '[/b]' => '</b>'); // Loop through the array and replace each key with its value in the string. foreach($mysyntax as $script => $html) { // Do once for lower case.. $str = str_replace($script, $html, $str); // And once for upper case.. $script = strtoupper($script); $str = str_replace($script, $html, $str); } return $str; } echo parse_script($myformtxt); --- Kevin ----- Original Message ----- From: "Tony Harrison" <tonyh21@tharrison21.fsnet.co.uk> To: <php-general@lists.php.net> Sent: Tuesday, September 03, 2002 12:22 PM Subject: [PHP] FORUM CODE > Hi, im wondering how in popular forum software, those 'BB codes' are done in > PHP, like, [B] and stuff. I just cant figure it out. > > ----------------------------- > tony@cool-palace.com > http://www.cool-palace.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#115098) next »