특정값 뽑아내는 법 채택완료
hanaro2
4년 전
조회 2,288
아래와 같은 내용이 ld_memo 칼럼에 있을때, 9L_tmU81tDc 이 값을 뽑아내고 싶습니다.
조언 좀 부탁드립니다.
하루 종일 방법을 찾아도 찾기가 힘드네요.
/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>
안녕하세요 반갑습니다.
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
채택된 답변
+20 포인트
마르스컴퍼니
Expert
4년 전
</p>
<p>$contents = '<iframe width="1280" height="720" src="<a href="https://www.youtube.com/embed/9L_tmU81tDc"" target="_blank" rel="noopener noreferrer">https://www.youtube.com/embed/9L_tmU81tDc"</a> frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';</p>
<p>preg_match_all("/<iframe[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $contents, $matches);</p>
<p>$src = $matches[1];</p>
<p>$arr = explode('/', $src[0]);</p>
<p>$last_part = array_pop($arr);</p>
<p>echo $last_part;</p>
<p>
로그인 후 평가할 수 있습니다
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인