php 정규식에 대해 질문드립니다. 정보
php 정규식에 대해 질문드립니다.본문
preg_match_all을 이용해 특정 문자열 사이에있는 정보를 얻어오고 싶습니다.
예를 들면
<span class="a">
123
321
</span>
이런 부분에서 <span class="a">부터</span>까지의 문자열을 가져오고싶습니다.
여기가 질문드려도 괜찮은 게시판인지 모르겠네요...
추천
0
0
댓글 2개

<?php
$str = '
<span class="a">
123
321
</span>';
preg_match_all('/<span[^>]+>(.*)<\/span>/s', $str, $matches);
print_r($matches);
?>
이런것 말씀이신가요?
결과 :
Array
(
[0] => Array
(
[0] => <span class="a">
123
321
</span>
)
[1] => Array
(
[0] =>
123
321
)
)
$str = '
<span class="a">
123
321
</span>';
preg_match_all('/<span[^>]+>(.*)<\/span>/s', $str, $matches);
print_r($matches);
?>
이런것 말씀이신가요?
결과 :
Array
(
[0] => Array
(
[0] => <span class="a">
123
321
</span>
)
[1] => Array
(
[0] =>
123
321
)
)
제가 원하는 정보인것 같습니다! 감사합니다ㅜㅜ