Parsing BBcode?

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
zenhop
Forum Newbie
Posts: 18
Joined: Mon Jan 19, 2009 2:18 pm

Parsing BBcode?

Post by zenhop »

hello.

Here is a simple question:
How can I detect this code and replace it with the return of a php function?

code to detect and parse:
<fb:message title="hello">world</fn:function>

PHP function:
function parse_message($title, $content) {
return "<b>$title</b><br />$content";
}

Thank you in advance!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Parsing BBcode?

Post by Burrito »

Code: Select all

 
$output = preg_match('/<fb:message title="(.*?)">(.*?)<\/fn:function>/', $input, $matches);
 
Post Reply