2012-02-03 3 views

답변

0

나는 actaully 당신이 워드 프레스 내가 그것을 테스트이 전까지 어떻게하는지보고 말하고 싶었 그리고 난 개방 된 div하여 쉽고 내가 이걸 발견 어쨌든

을 colosing 나의 페이지를 깰 수 ^^ 걱정하지 않는 워드 프레스를 발견 .

/** * close all open xhtml tags at the end of the string 
* * @param string $html 
* @return string 
* @author Milian <[email protected]> 
*/function closetags($html) { 
    #put all opened tags into an array 
    preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); 
    $openedtags = $result[1]; #put all closed tags into an array 
    preg_match_all('#</([a-z]+)>#iU', $html, $result); 
    $closedtags = $result[1]; 
    $len_opened = count($openedtags); 
    # all tags are closed 
    if (count($closedtags) == $len_opened) { 
    return $html; 
    } 
    $openedtags = array_reverse($openedtags); 
    # close tags 
    for ($i=0; $i < $len_opened; $i++) { 
    if (!in_array($openedtags[$i], $closedtags)){ 
     $html .= '</'.$openedtags[$i].'>'; 
    } else { 
     unset($closedtags[array_search($openedtags[$i], $closedtags)]); } 
    } return $html;} 

이 값은 찾고있는 값이어야합니다.

0

이것은 매우 복잡한 주제이며 일반적으로 쉬운 바로 가기가 아닙니다. 바퀴의 재발 명을 시작하기 전에 정확하게 작업하도록 설계된 라이브러리를 사용하십시오. 아마도 HTML Purifier은 소수의 도서관 중 하나 일뿐입니다.

관련 문제