리스트에서 에디터 이미지 여러개

리스트에서 에디터 이미지 여러개

QA

리스트에서 에디터 이미지 여러개

답변 4

본문

<?php
            $n = 0;
            for ($i=0; $i < $list_cnt; $i++) { 

                // 글수 체크
                if (!$list[$i]['is_notice'])
                $n++;


                preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $list[$i]['wr_content'],$matches);

                $img = get_view_thumbnail($matches[1][0]);

 

한개 아닌 여러개 뽑아 올려면 어떻게 하면 될까요?

이 질문에 댓글 쓰기 :

답변 4

$pattern = "/<img.*?src=[\"']?(?P<url>[^(http)].*?)[\"' >]/i";

                preg_match($pattern,stripslashes(str_replace('&','&',$list[$i]["wr_content"])), $match);

                $img = substr($match['url'],1);

 

이것도 여러개 안되나요? 하나씩 해야 되요?

이미지가 두 개인 게시물에서
preg_match($pattern,stripslashes(str_replace('&','&',$list[$i]["wr_content"])), $match);
이후에
print_r( $match);
라고 하셔서 배열이 어떤 형식인지 한번 파악해 보세요.

print_r( $match); 에서 한개밖에 안나옵니다. 이미지가 3개인데 이미지 하나만 나오네요.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 502
© SIRSOFT
현재 페이지 제일 처음으로