help with usort cmparison
Hi Everyone!
It's getting really cold here & I can't seem to wrap my frozen brain cells around this problem.
Below is my code to parse a YouTube feed which works fine.
I just need to sort entries by their $pubDate and I can't make it work.
<?php
//empty variable for the end
$html = ' ';
//URL of playlist feed
$feed = "http://www.youtube.com/feeds/videos.xml?playlist_id=PLC02CFDE5690E4010";
//Load feed xml
$xml = simplexml_load_file($feed);
//display 6 entries
for($i = 0; $i < 6; $i++) {
//node namespace variables
$published = $xml->entry[$i]->published;
//optional, shorten date
$shortDate = date("m/d/Y", strtotime($published));
$title = $xml->entry[$i]->title;
$id = $xml->entry[$i]->id;
//strip unwanted characters from ID
$id = str_replace ("yt:video:", "", $id);
$author = $xml->entry[$i]->author->name;
$uri = $xml->entry[$i]->author->uri;
//put node variables into html tags & embedded youTube player.
$html .= "<div class='col-sm-6 col-md-4'>
<h4><a href='$uri'>$title</a></h4>
<iframe src='http://www.youtube.com/embed/$id' allowfullscreen>
</iframe><br>
<small>Published: $shortDate By: $author</small>
</div><hr>";
}
//output to html code
echo $html;
?>
Parsed feed results: http://alt-web.com/DEMOS/my_feed.php
Any & all suggestions are appreciated.
Thanks,
Nancy O.

