Kevin Stone wrote: > $myformtxt = '[i]Hello[/i] [B]world[/B]'; // pretend this came from a form.
1. I understand what you're doing, and how. But what I don't understand is why? If a user is going to have to type [B]bold[/B], why not just get them to type <b>bold</b>. [bold] and [italic] maybe? 2, I think regular expressions are a safer way to go. That way you don't end up inserting eroneous html into peoples text if an unmatched tag is encountered. Square brackets will not throw a browser off track but an unclosed <h1> or <em> tag could ruin a page's appearance. i suggest using preg_replace, maybe like this: $pair = array( 'bold' => 'strong', 'italics' => 'em', 'heading1' => 'h1', 'heading2' => 'h2', 'heading3' => 'h3', 'heading4' => 'h4'); $pattern = array(); $replace = array(); foreach($pair as $key => $val) { $pattern[] = '/(\[)(' . $key . ')(\])([^]].*)(\[\/)(' . $key . ')(\])/i'; $replace[] = "<$val>" . '$4' . "</$val>"; } $new_body= preg_replace ($pattern, $replace, $body_text); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php