Reputation: 1220
I would like to access 'Organisation, support et services' in this array, is it possible ?
var_dump result of unassociated variable :
array (size=2)
'Organisation, support et services' =>
array (size=3)
54 => string 'Architecture d'entreprise' (length=25)
55 => string 'Outils de collaboration et patrimoine informationnel' (length=52)
53 => string 'Sécurité' (length=10)
'Applications' =>
array (size=3)
52 => string 'Système d'information activités recherche' (length=43)
50 => string 'Système d'information budget, finance, compta' (length=46)
51 => string 'Système d'information ressources humaines et paie' (length=50)
var_dump($unassociated);
foreach ($unassociated as $value) {
//var_dump($value[0]);
foreach ($value as $key => $value) {
echo '<input type="checkbox" class="checkbox_evaluateur" name="" id="' . $key . '">' . $value . '<br/>';
}
}
I tried $value[0] but i get null.
When i var_dump inside the first foreach i get :
array (size=3)
52 => string 'Système d'information activités recherche' (length=43)
50 => string 'Système d'information budget, finance, compta' (length=46)
51 => string 'Système d'information ressources humaines et paie' (length=50)
i would like to get 'Applications' wish is just before this array.
Upvotes: 0
Views: 671
Reputation: 18577
You are giving same $value
name while looping child loop.
foreach ($unassociated as $key => $value) {
//var_dump($value[0]);
foreach ($value as $key1 => $value1) {
echo '<input type="checkbox" class="checkbox_evaluateur" name="" id="' . $key1 . '">' . $value1 . '<br/>';
}
}
Upvotes: 1
Reputation: 352
You can try to check the key of the current array on foreach
:
foreach ($unassociated as $key => $value) {
//var_dump($value[0]);
if ($key == 'Applications') {
foreach ($value as $key2 => $value2) {
echo '<input type="checkbox" class="checkbox_evaluateur" name="" id="' . $key2 . '">' . $value2 . '<br/>';
}
}
}
Upvotes: 1