iframe 내용만 뽑아오기

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
iframe 내용만 뽑아오기

QA

iframe 내용만 뽑아오기

본문

아래와 같이 iframe 코드가 2개 내용에 들어 있습니다.

첫번재 iframe만  뽑아오고 싶습니다.

조언 좀 부탁드립니다.

 

 

/iframe width="1280" height="720" src="https://www.youtube.com/embed/9L_tmU81tDc" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe/

 

/iframe width="1280" height="720" src="https://www.youtube.com/embed/9L_tmU81tDc" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe/

이 질문에 댓글 쓰기 :

답변 1

만약 iframe 이 저렇게 순서대로 고정되서 출력한다고 치면 간단하게

$iframe_ex = explode('<iframe width="1280" height="720" src="', $content);
$iframe_ex = explode('" frameborder', $iframe_ex[1]);
echo $iframe_ex[0]; // 실질적으로 주소가 출력됨

이정도면 될것같고..

preg_match_all 은 정규식을 사용하셔서 하실 수 있습니다.


$pattern ='/(src=|href=)(\'|\")?([^<>\s\'\"]*)(\'|\"|\s|)/i';

preg_match_all( $pattern, $subject, $matches );


print_r($matches) 하셔서 원하는 곳을 출력하시면됩니다.

 

답변을 작성하시기 전에 로그인 해주세요.
전체 78
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT