我努力實踐捲曲,但並不順利 Pleasw告訴我,什麼是錯的 這裏是我的代碼如何使用捲曲的preg_match _all DIV內容
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://xxxxxxx.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, "Google Bot");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$downloaded_page = curl_exec($ch);
curl_close($ch);
preg_match_all('/<div\s* class =\"abc\">(.*)<\/div>/', $downloaded_page, $title);
echo "<pre>";
print($title[1]);
echo "</pre>";
和警告Notice: Array to string conversion
我要解析HTML是這樣
<div class="abc">
<ul> blablabla </ul>
<ul> blablabla </ul>
<ul> blablabla </ul>
</div>
$標題不是一個數組,但數組的數組。查看手冊頁上的示例:http://php.net/manual/en/function.preg-match-all.php – Ashalynd