1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
function read_xml($fichier, $item, $champs){
if($chaine = @implode("", @file($fichier))){
$tmp = preg_split("/<\/?".$item.">/",$chaine);
for($i=1;$i<sizeof($tmp)-1;$i+=2)
foreach($champs as $champ){
$tmp2 = preg_split("/<\/?".$champ.">/",$tmp[$i]);
$tmp3[$i-1][] = @$tmp2[1];
}
return $tmp3;
}
}
$tab = array("para","cescription","link","suite");
$xml = read_xml("text.xml","body",$tab);
foreach($xml as $row){
echo $row[0].' ';
echo $row[1].' ';
echo '<a href="#">'.$row[2].'</a> ';
echo $row[3];
} |
Partager