小编gtb*_*boy的帖子

为什么我的列表不能用PHP呈现?

我正在制作一个小型RSS阅读器,我希望它能够解析一个网站并列出一个feed.但是<ul><li>没有呈现和标签.有什么建议?

<?php
header("Content-Type: text/plain; charset=utf-8");

function jobs() {
    $output = array();
    $feed_url = 'http://www.jobs.ge/rss/jobs/';
    $feed = simplexml_load_file($feed_url);

    for($j=0; $j<10; $j++){

        $title = $feed ->channel->item[$j]->title;
        $link = $feed ->channel->item[$j]->link;
        $desc= $feed ->channel->item[$j]->description;
        $date = $feed ->channel->item[$j]->pubDate;

        $output[] = array (
            'title' =>$title,
            'link' =>$link,
            'description'=> $desc,
            'date'=> $date,
        );
    }
    return $output;
}

$feed = jobs();
?>

<ul>
<?php
    foreach ($feed as $item) {
        echo '<li>', $item['title'],'</li>';
    }
?>
</ul>
Run Code Online (Sandbox Code Playgroud)

html php html-lists

0
推荐指数
1
解决办法
95
查看次数

标签 统计

html ×1

html-lists ×1

php ×1