php help: how to transform characters that are between certain tags?

This topic is 4323 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello, I'm looking for some help with php code for my website. I have a blog, and I want to add [ code ] [ /code ] sections in it so I can write code easier (instead of now how I just replace tabs with 4   ). It uses some regex expressions for the bbcode implementation part, so I figure I should add in the "code" parse in that same section. Anyway, Is there anyway in php to call a function with all the data in a certain part of a regex expression? The regex patter would probably look like: "'$code$(.+?)$/code$is'" And I want to be able to replace it with something like: 'some_custom_func(data_represented_by_the_[.+?]part_of_regex_expr)' Is there a way to do this? Or some other way without having to iterate through the entire blog post? Thanks. Oh and since I'm on this topic, anyone recommend any code beautifiers that I can use for the "some_custom_func" part above?

Share on other sites
Quote:
 Original post by JohnBSmallNot quite preg_replace:preg_replace_callback()John B

That looks perfect. Thanks.

@ Colin Jeane I'd love to read that but are you sure that's a valid link?

1. 1
2. 2
3. 3
4. 4
frob
15
5. 5

• 10
• 12
• 20
• 12
• 13
• Forum Statistics

• Total Topics
632148
• Total Posts
3004450

×