else if 구분 좀 알수있을까요? 채택완료

6년 전 조회 2,515

 

Copy
if(!function_exists('get_og_from_html')) {
    function get_og_from_html($html){        
        $enc = mb_detect_encoding($html, array("UTF-8", "EUC-KR", "SJIS"));        
        libxml_use_internal_errors(true);
        $doc = new DomDocument();
        $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', $enc));
        $xpath = new DOMXPath($doc);
        $query = '//*/meta[starts-with(@property, \'og:\')]';
        $metas = $xpath->query($query);
        $og = array();
        foreach ($metas as $meta) {
            $property = $meta->getAttribute('property');
            $content = $meta->getAttribute('content');
            $og[$property] = $content;
        }        
        return $og;
    }
}

 

property 일때 <meta property ="og:title"

name    일때  <meta name="og:title"

로 나타내고 싶은데 실력이 너무 없습니다.

좀 알려주세요~~

 

답변 1개

감사합니다.~~

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고