Answer the question
In order to leave comments, you need to log in
Why doesn't iterate over references in foreach php?
Help, array enumeration not working.
There is an array with links:
$ssil12
The task is to connect the script for processing one link (parser),
iterate through the array with links, executing the script for each link:
foreach ($ssil12 as $https) {
perebor($https);
}
function perebor ($https='') {
//обрабатывает ссылку, вносит в бд спарсенные строки
}
$html = str_get_html($https); //получаем объек
Answer the question
In order to leave comments, you need to log in
If I correctly understood the condition of the problem, then the array $ssil12
contains links (in the sense of the url of the pages that need to be processed).
Further in the loop, you iterate over this array and eventually pass each individual link to the function call. str_get_html($https);
But judging by the documentation ( https://simplehtmldom.sourceforge.io/manual.htm) , it takes not a link as input , the html code of the page. Thus, you forgot to download the page itself from the link, for example, like this:
$content = file_get_contents($https)
$domObject = str_get_html($content);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question