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 32 33 34 35 36 37 38 39 40 41 42
|
<?php
function lit_xml($fichier,$item,$champs) {
// on lit le fichier
if($chaine = @implode("",@file($fichier))) {
// on explode sur <item>
// Dans l'exemple il s'agit de 'profil'
$tmp = preg_split("/<\/?".$item.">/",$chaine);
// pour chaque <item> donc tous les profils
for($i=1;$i<sizeof($tmp)-1;$i+=2)
// on lit les champs demandés <champ>
foreach($champs as $champ) {
$tmp2 = preg_split("/<\/?".$champ.">/",$tmp[$i]);
// on ajoute l'élément au tableau
$tmp3[$i-1][] = @$tmp2[1];
}
// et on retourne le tableau dans la fonction
return $tmp3;
}
}
// Lecture du FLUX XML sur le serveur
$xml = lit_xml("http://","champ",array("champ1","champ2","champ3"));
// Une petite boucle suffit pour retrouver les élément du tableau
// retourné dans la fonction lit_xml()
foreach($xml as $row) {// ici lz probléme argument invalid
echo("<div style=\"background-image:url('img/ranking/bg_top5.gif');\"");
echo ("<table><tr>");
echo ("<td><a href=\"$row[2]\"><img src=\"$row[0]\"></a></td>");
echo ("<td style=\"color:#FFFFFF;font-weight:bold;\" ><a href=\"$row[2]\">$row[1]</a></td>");
echo ("</div>");
}
?>
merci de m'aidé s'il vous plait :) |