我试图用SimpleHTMLDom做一个刮,似乎是运行到一个问题。PHP SimpleHTMLDom抓取问题
我的代码如下:
$table = $html->find('table',0);
$theData = array();
foreach(($table->find('tr')) as $row) {
$rowData = array();
foreach($row->find('td') as $cell) {
$rowData[] = $cell->innertext;
}
$theData[] = $rowData;
}
function array_find($needle, array $haystack)
{
foreach ($haystack as $key => $value) {
if (false !== stripos($needle, $value)) {
return $key;
}
}
return false;
}
$searchString = "hospitalist";
$position = array_find($searchString, $theData);
echo ($position);
这产生以下错误:
Warning: stripos() [function.stripos]: needle is not a string or an integer in C:\xampp\htdocs\main.php on line 85
我在做什么错?
它说针是不是字符串,并应 – Ibu