I’ve got a string like this:
Here is my code sample, its not too great:
[CODE]
<?php
echo "Some testing...";
?>
[/CODE]
I hope you enjoy.
Now I want to replace ALL occurrences of [CODE] … [/CODE] with the return value of highlight_string($content_of_CODE). The [CODE]..[/CODE]-pair may appear multiple times in the string.
How can I solve this without using eval?
Thank you for your help!
Assuming
[CODE]blocks are not nested,preg_replace_callback()is a perfect candidate.