Page 1 of 1

Help Looping This

Posted: Tue Dec 15, 2009 6:51 pm
by Judgement
Driving me up a %#*$#)$*) wall. I'm really not great with PHP and I can't figure out how to loop this for the life of me. It's basically taking a RSS feed and splitting it up so I can put it into a dynamic image.

Here's my (long) code:

Code: Select all

// Descriptions
$items = explode('<description>', $page);
$item1 = explode('</description>', $items[2]);
$item1 = $item1[0];
$item2 = explode('</description>', $items[3]);
$item2 = $item2[0];
$item3 = explode('</description>', $items[4]);
$item3 = $item3[0];
$item4 = explode('</description>', $items[5]);
$item4 = $item4[0];
$item5 = explode('</description>', $items[6]);
$item5 = $item5[0];
 
// Times
$times = explode('<pubDate>', $page);
$time1 = explode('</pubDate>', $times[1]);
$time1 = $time1[0];
$time2 = explode('</pubDate>', $times[2]);
$time2 = $time2[0];
$time3 = explode('</pubDate>', $times[3]);
$time3 = $time3[0];
$time4 = explode('</pubDate>', $times[4]);
$time4 = $time4[0];
$time5 = explode('</pubDate>', $times[5]);
$time5 = $time5[0];
Now I need to do that, just faster/easier. If there is a completely different way to do it, I'll go with that if it's better.

Help please.

Re: Help Looping This

Posted: Tue Dec 15, 2009 7:13 pm
by requinix
There is a better way: SimpleXML and a foreach.