I have a script that's scraping images from a website (4chan). It's having to do it by getting the url from the anchor tags not the image, else it would only get the thumbnails. The problem is that the url for the image appears in two anchor tags, thus each image appears twice.
I've tried putting them into an array and then applying array_unique() but it doesn't work.
Here's my code:
foreach($html->find('a') as $element) {
if (strpos($element->href, "/src/")){
$a = $element->href;
$ht = "<img src=\"" . $a. "\" />\n";
$arr = array($ht);
$arr = array_unique($arr);
foreach($arr as &$b) {
echo $b;
}
}
}
Thanks for any help in advance!