我想在 div 中提取 div 标签...
post.php 文件:
<body>
<div class="home">
<div id="post_message_14674248">Content number 14674248</div>
<div id="post_message_14674255">Content number 14674255</div>
<div id="post_message_14674278">Content number 14674278</div>
<div id="post_message_14674279">Content number 14674279</div>
<div id="post_message_14674283">Content number 14674283</div>
<div id="post_message_14674290">Content number 14674290</div>
.
.
.
.
</div>
</body>
extract.php 文件:
<?php
$html = file_get_contents("post.php");
$pattern = "/(<div id=\"post_message_)(.*)(<\/div>)/";
preg_match_all($pattern, $html, $matches);
print_r($matches);
?>
但它给了我一个空数组:
Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) [3] => Array ( ) )
我想要这样:
Content number 14674248
Content number 14674255
Content number 14674278
Content number 14674279
Content number 14674283
Content number 14674290
有什么帮助吗?