如何使用foreach获取PHP数组中的数据?

时间:2011-02-07 07:45:32

标签: php

我有这样的数据,我需要将其变为使用变量请告诉我如何让它们变量

Array
(
    [data] => Array
        (
            [0] => Array
                (
                    [name] => xxxxxxxxxxxx
                    [category] => yyyyyyyy
                    [id] => 12345666666
                    [data] => ABCDE
                )

            [1] => Array
                (
                     [name] => ZZZZZZZZZZZ
                    [category] => JJJJJJ
                    [id] => 88888888888888
                    [data] => ABCDEHIJK
                )

        )

)

谢谢你的不同。

1 个答案:

答案 0 :(得分:1)

foreach ($array['data'] as $data) {
    echo $data['name'];
    echo $data['category'];
    ...
}

http://php.net/manual/en/control-structures.foreach.php