Je n'arrive pas à faire un boucle qui parait pourtant simple en gros je voudrais créer une boucle pour afficher les images sans devoir encoder toutes les lignes voici une partie du code xml renvoyer par le webservice :
Voici la boucle que j'ai commencé :
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 SimpleXMLElement Object ( [OFFRE] => SimpleXMLElement Object ( [LECODE] => 00001 ( [CHAR_LOC] => 0 [MODI_DATE] => 10/02/2012 [IMG_01] => http://www.monsite.com/Photos/IMG/000000735684.jpg [IMG_02] => http://www.monsite.com/Photos/IMG/000000735685.jpg [IMG_03] => http://www.monsite.com/Photos/IMG/000000735686.jpg [IMG_04] => http://www.monsite.com/Photos/IMG/000000735604.jpg [IMG_05] => http://www.monsite.com/Photos/IMG/000000735614.jpg [IMG_06] => http://www.monsite.com/Photos/IMG/000000735624.jpg [IMG_07] => SimpleXMLElement Object ( ) [IMG_08] => SimpleXMLElement Object .... ect ( )
Voilà merci de votre aide
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 $contenu = curl_exec($curl); $xml = new SimpleXMLElement($contenu); // affichage des flux echo"<pre>". print_r($xml,1)."</pre>"; //Création de la boucle foreach ($xml->OFFRE as $variable) { echo $variable->LECODE;} // jusque là tout va bien // ce qui fonctionne c'est ça echo '<p><img src="'.$variable->IMG_03.'"alt="image"></p>'; // le but c'est de pouvoir avoir IMG_ $i est d'avoir une numérotation auto mais je m'en sort pas dans la syntaxe // ce qui ne fonctionne plus mais j'avoue que c'est du bricolage là /* for( $i = 01; $i < 20; $i++ ) $photo = $v->PHOTO_.$i; // echo '<img src="'.$v->$photo.'"alt="photoTest"></p>'; echo $photo . '<br />'; ; }*/
Partager