Bonjour à tous,
J’ai un petit problème dans une page en PHP, il marche presque à perfection(il s’agit d’un lecteur rss en php), mais les caractères speciaux (&xxx;)de l’HTML saffichent à la place des caractères normaux, pouvez-vous m’aider?
Voici le code:
[spoiler]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Création et lecture de flux RSS 2.0 en PHP</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="robots" content="All"/>
<meta name="keywords" content=""/>
<link rel="stylesheet" href="exemple.css" type="text/css"/>
</head>
<body>
<?
// 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://p.yimg.com/dj/rss/technologies.xml",array("title","link","description","pubDate",));
// et on affiche...
foreach($rss as $tab) {
echo '<div class="news_box">
<div class="news_box_title">'.$tab[0].'</div>
'.$tab[2].' <a href="'.$tab[1].'">Lire tout l\'article</a>
</div>';
}
?>
</body>
</html>
[/spoiler]
Merci d’avance,
Igor.
Edité le 29/05/2010 à 12:44