I’m trying to run the preg_replace() function to replace the content in between two custom tags (i.e. [xcode]) within the string / content of the page.
What I want to do with the content between these custom tags is to run it through highlight_string() function and to remove those custom tags from the output.
Any idea how to do it?
So you want sort of a BBCode parser. The example below replaces
[xcode]tags with whatever markup you like.Use
preg_replace_callback()if you want to pass the matched text to a function:I’ll include the source code of a BBCode parser that I made a long time ago. Feel free to use it.