mercredi 8 juillet 2015

domcrawler loop and if statement to check if class exists

Hi I'm running into a little problem with DomCrawler. I'm scraping a page and it has a div with a class of .icon3d. I want to go through the page and for every div with that class I will add an "3D" item to an array, and every div without it I will add a "2D" item. Here is the code I have so far.

or ($i=0; $i < 10; $i++) { 
    $divs =  $crawler->filter('div.icon3d');
        if(count($divs)){
            $type[] = '3D';
        }else{
            $type[] = '2D';
        }
    }

Aucun commentaire:

Enregistrer un commentaire