Hi everyone,
for a little scraper I have a array (from a list with 'URLs ):
$pages_to_fetch = [uri1, uri2, ...];
which I would like to use with
$pages->find($pages_to_fetch)
Can I achieve this?
I have to tried to call “$pages->find()” looping through the array but then I can’t figure out how to merge the results into a regular “$page” object…
Well we also could do something like so:
$pages_to_fetch = ['uri1', 'uri2', ...]
$fetch_results = array();
foreach ($pages_to_fetch as $page_to_fetch) {
$fetch_results[] = $pages->find($page_to_fetch);
}
foreach ($fetch_results as $fetched_page) {
echo $fetched_page->title()
...
}
Hmm just for completeness, I can do also this - to narrow it down a bit, it looks like this:
$collection = $pages->find(['tags/shoes', 'tags/bananas']);
foreach($collection as $item) {
echo $item->title();
}
It should works fine.