0

How do I display more elements with simple_html_dom? The code I have right now works great, but.... It only loops the portfolio-caption. I want to display more items then Caption / Category. My problem is, the items I want to display are not in the div with the class portfolio-caption ( it's outside the div ). I tried to replace portfolio-caption with body but then it only loops once.

// Include the php dom parser    
include_once 'simple_html_dom.php';

// Create DOM from URL or file

$html = file_get_html('http://blackrockdigital.github.io/startbootstrap-agency/');
$items = array();
// Find all links 
foreach($html->find('div.portfolio-item .portfolio-caption') as $element) {
    $items[] = array(
        'Caption' => $element->find('h4', 0)->innertext,
        'Category' => $element->find('p', 0)->innertext
    );
}

foreach($items as $result){
    echo $result['Caption'];
    echo $result['Category'];
}

I don't have a idea how to do it. Maybe make a foreach for every element? But that is a mess.

Rexie Galban
  • 88
  • 1
  • 1
  • 6
hello123
  • 33
  • 8

0 Answers0