Bonsoir
Je souhaiterai limiter l'affichage à 5 informations du flux RSS que j'affiche sur ma page.
Mais là je ne vois plus...
Si vous pouvez me débloquer ...
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <? // Lecture d'un fichier XML function lit_rss($fichier,$champs) { // on lit le fichier if($chaine = @implode("",@file($fichier))) { // on explode sur <item> $tmp = preg_split("/<\/?"."item".">/",$chaine); // pour chaque <item> for($i=1;$i<sizeof($tmp)-1;$i+=2) // on lit les champs demand? <champ> foreach($champs as $champ) { $tmp2 = preg_split("/<\/?".$champ.">/",$tmp[$i]); // on ajoute au tableau $tmp3[$i-1][] = @$tmp2[1]; } // et on retourne le tableau return $tmp3; } } $rss = lit_rss("http://www.jeuxvideo.fr/xml/rev.xml",array("title","link","description","pubDate", "url")); // et on affiche... foreach($rss as $tab) { echo '<div class="news_box"> <div class="news_box_title">'.$tab[0].'</div> <div class="news_box_date">posté le '.date("d/m/Y",strtotime($tab[3])).'</div> '.$tab[2].' <a href="'.$tab[1].'">Lire tout l\'article</a> </div>'; } ?>








Répondre avec citation




Partager