Schließen Sie die HTML-Tags
Ein weiterer Ansporn, um PHP . Zu diesem Zeitpunkt schließen wir die unverschlossene HTML-Tags. Ich weiß nicht, wo es vielleicht nützlich sein ...
function closetags($html) {
$single_tags = array('meta','img','br','link','area','input','hr','col','param','base');
preg_match_all('~< ([a-z0-9]+)(?: .*)?(? ~iU', $html, $result);
$openedtags = $result[1];
preg_match_all('~~iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
if (count($closedtags) == $len_opened) {
return $html;
}
$openedtags = array_reverse($openedtags);
for ($i=0; $i < $len_opened; $i++) {
if (!in_array($openedtags[$i], $single_tags)) {
if (FALSE !== ($key = array_search($openedtags[$i], $closedtags))) {
unset($closedtags[$key]);
}
else {
$html .= ' ';
}
}
}
return $html;
} '.$openedtags[$i].'>
function closetags($html) {
$single_tags = array('meta','img','br','link','area','input','hr','col','param','base');
preg_match_all('~< ([a-z0-9]+)(?: .*)?(? ~iU', $html, $result);
$openedtags = $result[1];
preg_match_all('~~iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
if (count($closedtags) == $len_opened) {
return $html;
}
$openedtags = array_reverse($openedtags);
for ($i=0; $i < $len_opened; $i++) {
if (!in_array($openedtags[$i], $single_tags)) {
if (FALSE !== ($key = array_search($openedtags[$i], $closedtags))) {
unset($closedtags[$key]);
}
else {
$html .= ' ';
}
}
}
return $html;
}
function closetags($html) {
$single_tags = array('meta','img','br','link','area','input','hr','col','param','base');
preg_match_all('~< ([a-z0-9]+)(?: .*)?(? ~iU', $html, $result);
$openedtags = $result[1];
preg_match_all('~~iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
if (count($closedtags) == $len_opened) {
return $html;
}
$openedtags = array_reverse($openedtags);
for ($i=0; $i < $len_opened; $i++) {
if (!in_array($openedtags[$i], $single_tags)) {
if (FALSE !== ($key = array_search($openedtags[$i], $closedtags))) {
unset($closedtags[$key]);
}
else {
$html .= ' ';
}
}
}
return $html;
}
Podsmotrenno hier


Kommentare
Noch keine Kommentare.