Array for each help

Started by Biology Forums, February 26, 2019, 01:09:48 PM

Previous topic - Next topic

Biology Forums

Array
(
    [0] => Array
        (
            [id] => 1
            [text] => N/A
        )

    [1] => Array
        (
            [id] => 2
            [text] => Alma College
        )

    [2] => Array
        (
            [id] => 3
            [text] => American University - Washington D.C.
        )

    [3] => Array
        (
            [id] => 4
            [text] => Appalachian State University : ASU
        )

    [4] => Array
        (
            [id] => 5
            [text] => Arizona State University : ASU
        )
)


I'd like to extract the id and text in every line echo'd as: id - text. How do I do this? The array is set as: $context['school'].

I tried:

foreach ($context['downloads_school'] as $i => $school)

But I kept getting "array" as the output

live627

echo $school['id']  . ' - ' . $school['text'];

Biology Forums


Advertisement: