Problems reading an RSS feed with SimpleXML Problems reading an RSS feed with SimpleXML codeigniter codeigniter

Problems reading an RSS feed with SimpleXML


foreach($xml->channel->item as $item) {    $article = array(); // so you want to erase the contents of $article with each iteration, eh?    $article['title'] = $item->description;}

You might want to look at your for loop if you're interested in more than just the last element - i.e.

$article = array();foreach($xml->channel->item as $item) {    $article[]['title'] = $item->description;}


If you want the data as a specific type, you'll need to explicitly type it:

foreach($xml->channel->item as $item) {    $article = array();    $article['title'] = (string) $item->description;}


Typecast the following explicitly to (string):

$item -> title$item -> link$item -> description