Home | Registrieren | Einloggen | Suchen | Aktuelles


Forum » PHP & MySQL » highlight_string Antworten
highlight_string

Can
Halbgott


Beiträge: 1330


Dann liefer doch gleich alles mit

Ne, im Ernst. Ich find, solche Funktionen wie str_before, str_after usw. sollten endlich mal in PHP enthalten sein...

---
"S-púrlawits'chkâ A-ngáse gûrewüdíx" - Zaphrot Bibelprox

  Profil   E-Mail   Editieren   Zitieren

c3o
Posting-Schinder


Beiträge: 586


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;
}



Testdokument:
1: 
2: 
3: 
4: 
5:
$text='Test Text ... blubb [php]<?php phpinfo(); ?>[/php] ..lala[php]<?=$lala ?>[/php]..';

echo hilite_php($text);

  Profil   E-Mail   Website   Editieren   Zitieren
Seite 1 | 2  

Antworten
Nach oben