Simple_html_dom获取标题和介绍并在我的页面上显示它们

As I want to understand Simple HTML Dom a bit I am playing around with it, to test options on my localhost.

Basically I want to take the titles and intro's of this website and display them on my page.

The title as <h2> and the intro as <p>.

What am I doing wrong?

<?php
include 'simple_html_dom.php';
// Create DOM from URL
$html = file_get_html('http://www.nu.nl/algemeen');

foreach($html->find('div[class=list-overlay]') as $article){
    $title['intro']    = $article->find('span[class=title]', 0)->innertext;
    $intro['details'] = $article->find('span[class=excerpt]', 0)->innertext;


    echo '<h2>'. $articles . '</h2>
    <p>'. $title .'</p>';
}
?>

edit: There was a double line in there.

Your soulution is somehow right. You have only few typos in variable names. Here is my editation of your code. Also I have added few comments to help you understand.

<?php
    include 'simple_html_dom.php';
    // Create DOM from URL
    $html = file_get_html('http://www.nu.nl/algemeen');

    // exctract all elements matching selector div[class=...]
    foreach($html->find('div[class=list-overlay]') as $article){
        // and for each extract first (0) element that matches to span[class=title]
        $title = $article->find('span[class=title]',   0)->innertext;
        // and do the same for intro, extract first element that belongs to selector
        $intro = $article->find('span[class=excerpt]', 0)->innertext;

        // and write it down simply
        echo '<h2>'. $title . '</h2>';
        echo '<p>' . $intro . '</p>';
    }
?>

This solution isn't good though. The have bad structure of their HTML so it is not easy to select only articles, because they don't have them in div with ID articles (for example. You are lucky man anyway, because they provide you XML feed of their articles that is much easier to parse (also less data to transfer and so on). You can find it here and extract titles and intros for your website.