<?php $text = 'bla bla bla [kod] <?php $v = \'bla\'; echo $v; ?> [/kod] bla bla'; $pattern = "|\[kod\](.*?)\[/kod\]|s"; echo preg_replace_callback($pattern, create_function('$m', 'return highlight_string($m[1], true);'), $text); ?>