ik ben bezig met het maken van de content formatting voor een site. In het begin wordt daar htmlspecialchars() gebruikt om alle <,>,&,",' om te zetten.
Vervolgens worden er zaken omgezet zoals [b] naar <b> etc.
Nu wou ik ook een tag invoeren [html] [/html] om toch gewone HMTL code toe te laten. Maar nu lukt het me niet echt om binnen die [html] codes htmlspecialchars() ongedaan te maken.
Wat ik had:
maar dat lukt niet. De pagina blijft eindeloos laden... waar zit het mis? als ik de for loop tussen commentaar zet gaat het sneller, maar worden de [html] blocks gewoon weggelaten.
Vervolgens worden er zaken omgezet zoals [b] naar <b> etc.
Nu wou ik ook een tag invoeren [html] [/html] om toch gewone HMTL code toe te laten. Maar nu lukt het me niet echt om binnen die [html] codes htmlspecialchars() ongedaan te maken.
Wat ik had:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| // If there are [html][/html] blocks
if (preg_match("/[html](.|\n)+?[\/html]/i",$aText,$htmlBlock)) {
//for each block
for ($i=1;$i<count($htmlBlock);$i++) {
// undo htmlspecialchars()
$htmlBlock[$i] = str_replace("<","<",$htmlBlock[$i]);
$htmlBlock[$i] = str_replace(">",">",$htmlBlock[$i]);
$htmlBlock[$i] = str_replace("&","&",$htmlBlock[$i]);
$htmlBlock[$i] = str_replace(""","\"",$htmlBlock[$i]);
$htmlBlock[$i] = str_replace("'","'",$htmlBlock[$i]);
//remove [html] and [/html] tags
//$htmlBlock[$i] = str_replace("[html]","",$htmlBlock[$i]);
//$htmlBlock[$i] = str_replace("[/html]","",$htmlBlock[$i]);
//replace the old code with the new
$aText = preg_replace("/[html](.|/n)+?\\[\/html]/i",$htmlBlock[$i],$aText);
}
} |
maar dat lukt niet. De pagina blijft eindeloos laden... waar zit het mis? als ik de for loop tussen commentaar zet gaat het sneller, maar worden de [html] blocks gewoon weggelaten.