Help Looping This

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Judgement
Forum Newbie
Posts: 5
Joined: Wed Aug 05, 2009 11:37 am

Help Looping This

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Help Looping This

Post by requinix »

There is a better way: SimpleXML and a foreach.
Post Reply