我使用簡單的HTML DOM解析器HTML DOM和strpos
foreach($html->find('a') as $element) {
//produce results
if(strpos($element, 'string')) {
$myarray[] = $element->href;
}
}
VS
foreach($html->find('a') as $element) {
//not producing result
if(strpos($element->href, 'string')) {
$myarray[] = $element->href;
}
}
爲什麼當我加入strpos起到元素 - > HREF,甚至從來都沒有檢測到的單詞序列壽href有字符串關鍵字。
任何機會,你可以發佈一些你正在解析的HTML(特別是有問題的href的位)? –