1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
function hilite_php($text) { $erg = split('\[/?php\]', $text); for($i=1;$i<count($erg);$i=$i+2) { $erg2[] = $erg[$i]; } for($i=0;$i<count($erg2);$i++) { $text = str_replace('[php]'.$erg2[$i].'[/php]', highlight_string($erg2[$i], true), $text); } return $text; }
1: 2: 3: 4: 5:
$text='Test Text ... blubb [php]<?php phpinfo(); ?>[/php] ..lala[php]<?=$lala ?>[/php]..'; echo hilite_php($text);