0

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.

0

2 Answers 2

1

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/>';
        }
    }

}
Sign up to request clarification or add additional context in comments.

Comments

1

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/>';
    }

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.