salutatous,
voici mon code (déclaration des variables et boucle)
j'obtiens ceci :
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 $nombre_de_pays = 11; $pays_1 = "tyrol_autrichien"; $pays_2 = "martinique"; $pays_3 = "reunion"; $pays_4 = "maurice"; $pays_5 = "italie"; $pays_6 = "croatie"; $pays_7 = "madere"; $pays_8 = "irlande"; $pays_9 = "ouest_americain"; $pays_10 = "equateur"; $pays_11 = "galapagos"; for($i=1; $i < $nombre_de_pays+1; $i++) { $debut = '$menu_secondaire_bouton_'; $milieu = '$pays_'.$i; $fin = '= "off";'; $complet = $debut.$milieu.$fin; echo $complet.'<br/>'; }
mais je voudrais que $pays_1, $pays_2, $pays_3... soient remplacés par le nom du pays correspondant déclaré plus haut, comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 $menu_secondaire_bouton_$pays_1= "off"; $menu_secondaire_bouton_$pays_2= "off"; $menu_secondaire_bouton_$pays_3= "off"; $menu_secondaire_bouton_$pays_4= "off"; $menu_secondaire_bouton_$pays_5= "off"; $menu_secondaire_bouton_$pays_6= "off"; $menu_secondaire_bouton_$pays_7= "off"; $menu_secondaire_bouton_$pays_8= "off"; $menu_secondaire_bouton_$pays_9= "off"; $menu_secondaire_bouton_$pays_10= "off"; $menu_secondaire_bouton_$pays_11= "off";
merci de vos lumières
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 $menu_secondaire_bouton_tyrol_autrichien= "off"; $menu_secondaire_bouton_martinique= "off"; $menu_secondaire_bouton_reunion= "off"; $menu_secondaire_bouton_maurice= "off"; $menu_secondaire_bouton_italie= "off"; $menu_secondaire_bouton_croatie= "off"; $menu_secondaire_bouton_madere= "off"; $menu_secondaire_bouton_irlande= "off"; $menu_secondaire_bouton_ouest_americain= "off"; $menu_secondaire_bouton_equateur= "off"; $menu_secondaire_bouton_galapagos= "off";
Partager