09-14-2011, 11:23 AM
Does somebody has a BBCode function for me?
And then i mean, not for 1 code, but for a few.
$string = "
And that it excecute all the bbcode
And also like this site, that text inside a php/code tag won't be transformed
Hope you can help me with this.
09-14-2011, 11:59 AM
This forum isn't for us to give you code, it's to aid your learning and give you advice to solve problems.
However, I will give you some example logic. You want to set up a set of rules, i.e. for this do this, and set up a preg_replace or str_replace to replace segments with your desired rule. It might be easier if you use recursion for this as well.
09-14-2011, 12:07 PM
How could i make a recursion for the rule in the first rule then?
Checking howmuch tags there's in a rule, and then loop that many trough a function?
09-14-2011, 12:14 PM
I think you're misunderstanding the concept of recursion. I'm not sure you even need it tbh. I'm sure you could define two arrays, one with patterns to find and one with patterns to replace with. Then, use preg_replace once to replace all your bbcode with your rules.
Would have to get confirmation on how that works though. I've seen it done similar to that, but not entirely confident on it as I hardly ever use preg_replace.
09-14-2011, 12:20 PM
If workerd with preg_match before, and kind of created this already once.
But only the quote workerd for the first time, and not the quote inside quote would be quoted :P
09-14-2011, 12:22 PM
Maybe that's where recursion comes in, with some sort of combination of preg_match to make sure you catch the stragglers :P
09-14-2011, 12:55 PM
I think i got it now ;)