TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-07-2010, 03:04 PM   #1 (permalink)
The Contributor
 
webosb's Avatar
 
Join Date: Nov 2007
Posts: 41
Thanks: 24
webosb is on a distinguished road
Default sorting simplexml data by date

Need help with sorting simplexml data by date.

I'm pulling data from an xml feed with simplexml. But the problem is the output doesn't have any kind of ordering. I want to be able to sort them by date. (sort order being from now to future) How would I go about that?

Date value is in this format: 2011-06-17 from $r25->start_date


Here's how my code looks

PHP Code:
$urL "http://www.domain.com/feed.xml";

$ch curl_init();
curl_setopt($chCURLOPT_URL$urL);
curl_setopt ($chCURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($chCURLOPT_USERPWD"username:password");
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_CONNECTTIMEOUT10);
$output curl_exec($ch);
curl_close($ch);

$feed $output;
$xml = new SimpleXmlElement($feed);
$msg ""

foreach(
$xml->children('http://www.testnet.com/r25') as $entry){
    
$namespaces $entry->getNameSpaces(true);
    
$r25 $entry->children($namespaces['r25']); 
    
$evDate date('F n, Y (l)',strtotime($r25->start_date));
    
$msg .= "<li><span class=\"date\">$evDate</span> - <span class=\"eventTitle\">$r25->event_name</span></li>\n\n";

__________________
"Things you can get access to, you should never memorize." -Albert Einstein
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
webosb is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Injection and mysql_real_escape_string Durux General 61 01-29-2013 12:20 PM
Venerable methods and the applications they are commonly trusted in. Village Idiot Tips & Tricks 7 11-06-2008 07:36 AM
SQLite vs SimpleXML; For small redundant data stewart General 4 03-14-2008 10:10 PM
The act of sharing your data Wildhoney General 0 12-06-2007 03:31 PM
Tips: PHP security Village Idiot Tips & Tricks 22 11-23-2007 11:17 PM


All times are GMT. The time now is 08:08 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design