htmlentities() in PHP ohne HTML-Tags zu zerstören
Hier meine Lösung für das Problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | function htmlentitiesOutsideHTMLTags ($htmlText) { $matches = Array(); $sep = '###HTMLTAG###'; preg_match_all("@<[^>]*>@", $htmlText, $matches); $tmp = preg_replace("@(<[^>]*>)@", $sep, $htmlText); $tmp = explode($sep, $tmp); for ($i=0; $i<count($tmp); $i++) $tmp[$i] = htmlentities($tmp[$i]); $tmp = join($sep, $tmp); for ($i=0; $i<count($matches[0]); $i++) $tmp = preg_replace("@$sep@", $matches[0][$i], $tmp, 1); return $tmp; } |
Das wird dich vielleicht auch interessieren:
No comments yet






