php - Embed BBCode within itself not working -


so working on simple php bbcode system, though doing [center][b][i]text[/i][/b][/center] doesn't parse. leaves couple out. curious if give me tip? or point me in direction learn how fix issue.

sample of code:

function bbcode($str) {   $patterns = array();   $patterns = array(     '#\[b\](.*?)\[/b\]#',     '#\[i\](.*?)\[/i\]#',     '#\[u\](.*?)\[/u\]#',     '#\[color=(.*?)\](.*?)\[/color\]#',     '#\[img\](.*?)\[/img\]#',     '#\[center\](.*?)\[/center\]#',     '#\n#'    );    $replacements = array();   $replacements = array(     '<strong>$1</strong>',     '<em>$1</em>',     '<u>$1</u>',     '<span style="color:$1">$2</span>',     '<img src="$1" style="max-width:45%;"></img>',     '<center>$1</center>',     '<br/>'   );     return preg_replace($patterns, $replacements, $str); } 


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -