So I'm implementing my own form of BBCode into my site, and need ideas of how to implement a code tag. Right now I just preg_replace the other tags, but this one is a bit more complicated.
What I was thinking was, I substr out the code tags into an array. Replace the code tags with something like {code1}. Format the code, then just replace {code1} with the code tag.
Seems like a clunky way to do it tho:
find first code tag
find first /code tag
substr
preg_replace with {code*}
replace needed html, only the first code tag tho
-repeat for every code tag
format text
replace each {code*} with the associated code in the text
Dealing with a code tag
Moderator: General Moderators
Re: Dealing with a code tag
You could do something like this.