par
justadnan » 03 mai 2016, 17:07
comment obtenir dernière élément Dans xml Commandé par dérniéer date ( pubdate ) ? Ou par d'autre moyen .. La chose importante est d'apporter la dernière chose a été publié

Merci
How to Get last element order by pubdate ?!
Code : Tout sélectionner
<?php
$rss = new DOMDocument();
$rss->load('http://www.theguardian.com/tv-and-radio/rss');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 1;
for($x=0;$x<$limit;$x++) {
$link = $feed[$x]['link'];
$date= $feed[$x]['date'];
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
/*
$date = date('l F d, Y', strtotime($feed[$x]['date']));
*/
$description= $feed[$x]['description'];
}
$videoTitle = $title;
$videoDesc = $description;
$linkfeed = $link;
?>
comment obtenir dernière élément Dans xml Commandé par dérniéer date ( pubdate ) ? Ou par d'autre moyen .. La chose importante est d'apporter la dernière chose a été publié :) Merci
How to Get last element order by pubdate ?!
[code]<?php
$rss = new DOMDocument();
$rss->load('http://www.theguardian.com/tv-and-radio/rss');
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array (
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
);
array_push($feed, $item);
}
$limit = 1;
for($x=0;$x<$limit;$x++) {
$link = $feed[$x]['link'];
$date= $feed[$x]['date'];
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
/*
$date = date('l F d, Y', strtotime($feed[$x]['date']));
*/
$description= $feed[$x]['description'];
}
$videoTitle = $title;
$videoDesc = $description;
$linkfeed = $link;
?>[/code]