1
如何使用preg匹配獲取此字符串的鏈接?使用preg匹配獲取標籤的內容全部
<h3 class='post-title entry-title'>
<a href='http://domain.blogspot.com/2011/03/blog-post_111.html'>Test Post</a>
</h3>
這是我做的,到目前爲止
<?php
$string = file_get_contents('http://www.domain.com');
$regex_pattern = "/<h3 class=\'post-title entry-title\'>([^`]*?)<\/h3>/";
unset($matches);
preg_match_all($regex_pattern, $string, $matches);
foreach ($matches[0] as $paragraph) {
echo $paragraph;
echo "<br>";
}
?>
謝謝!
您好CanSpice和感謝信息。請你能給我一個關於如何轉換我的代碼的例子嗎?我用它更新了我的帖子。 – EnexoOnoma 2011-03-24 20:29:23