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

Started by
3 comments, last by IFooBar 17 years, 6 months ago
Hello, I'm looking for some help with php code for my website. I have a blog, and I want to add 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?
[size=2]aliak.net
Advertisement
preg_replace()?
Not quite preg_replace:
preg_replace_callback()

John B
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
For reference, here's my explanation and implementation of a bbcode system.
Quote:Original post by JohnBSmall
Not 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?
[size=2]aliak.net

This topic is closed to new replies.

Advertisement