0

After a lot of attempts and research I can't figure it out and I hope someone can help me. I may be looking too far but I'm not getting the output I need in any way.

The following json output comes from an API:

Array
(
    [group] => Array
        (
            [name] => Iedereen
            [desc] => Iedereen
            [type] => G
            [instituteNumber] => Array
                (
                )
            [children] => Array
                (
                    [group] => Array
                        (
                            [0] => Array
                                (
                                    [name] => Beheerders
                                    [desc] => Beheerders
                                    [type] => G
                                    [code] => Beheerders
                                    [instituteNumber] => Array
                                        (
                                        )
                                )
                            [1] => Array
                                (
                                    [name] => Personeel
                                    [desc] => Personeel
                                    [type] => G
                                    [code] => Personeel
                                    [instituteNumber] => Array
                                        (
                                        )
                                    [children] => Array
                                        (
                                            [group] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [name] => DT
                                                            [desc] => directieteam
                                                            [type] => G
                                                            [code] => DT5
                                                            [instituteNumber] => Array
                                                                (
                                                                )
                                                        )

From this I want to use the following data: (All array groups under 'personeel')

[name] => DT
[type] => G

Can someone help me?

MisterS
  • 15
  • 4

1 Answers1

0

Found it :)

foreach ($iedereen as $alles) {

    foreach ($alles['children']['group'] as $hoofdgroepen) {

        if($hoofdgroepen['name'] == "Personeel"){

            foreach($hoofdgroepen['children']['group'] as $subgroepen) {

                echo $subgroepen['name']."<br />";

            }

        }

    }

}
MisterS
  • 15
  • 4