【发布时间】:2013-12-08 04:56:43
【问题描述】:
下面的代码从 yahoo 获取 rss 提要,它可以工作,但我有一个小问题,当我擦代码时,它会返回提要,但它也会给我一个错误,例如 -
未定义的偏移量:第 8 行 /Applications/MAMP/htdocs/feedbackFtms/rss.php 中的 1
line 8 is -
$foundImg = $findImg[1];
<div class="feed">
<link rel="stylesheet" href="css/profilepage.css">
<?php
function getImageFromContext($context){
$findImg = explode('<img src="',$context);
$foundImg = $findImg[1];
$findExt = explode('.jpg',$foundImg);
$getIMG = $findExt[0].'.jpg';
return $getIMG;
}
function getFeed($url){
$x = simplexml_load_file($url);
echo "<ul>";
foreach($x->channel->item as $entry) {
echo "<li><img src='".getImageFromContext($entry->description)."' /><a href='{$entry->link}' title='{$entry->title}'>{$entry->title}</a></li><br>";
}
echo "</ul>";
}
getFeed("http://news.yahoo.com/rss/entertainment");
?>
</div>
【问题讨论】:
-
问题出在第 7 行,
explode没有找到任何可爆炸的地方。 -
嘿迈克,请向我解释更多...不是真正的 php n 东西专家