![]() |
BBCode preg_match => str_replace
G'd evening guys,
I'm trying to get a BBCode editor to work. In code tags for PHP, I've got this; PHP Code:
I myself thought first of str_replace, but then you'll need to search into the code tags if ANY BBCode is present... Anyways, I am out of options so maybe the RegEx specialist or BBCode specialists could help me out. ReSpawN |
Aha, you've stumbled on the old switcheroo! What do I mean? Well, process [ code ] bbCode first and replace it with a {codeblock_#}, and push the actual code inside the tags to an array with an index of "codeblock_#". To do this you'll have to do a preg_replace with a callback and return the string based off a global variable you initialize to zero for each post. Then at the end use a standard call to:
PHP Code:
|
RobertK member of the month February! :P Darn man, you're pretty good at it! Loved your other post about hashes as well. Thanks very much.
|
Wow, thanks. :-) I've only been a member a few days, and already my little tricks are well liked.
I'm always glad to help. I noticed that one in SMF, as their code was so easily untouched I was curious as to why. And that happens to be their method. Just placeholder it. |
Quote:
|
Could be a nice start for sure. I'll work the concept out in a few days. Let me get back to it on that.
|
| All times are GMT. The time now is 02:15 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0