I am using simple html dom parser
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;
}
}
Why when i add strpos function to element->href, it never detect the word string even tho the href has string keyword.
strpos('monkey', 'm')will return0.0will be seen as false by PHP. If$element->hrefstarts withstring, it will not go inside the if.Use
or