迭代数组并获取键和值[重复]

问题描述 投票:0回答:1

我需要迭代动态数组。该数组将如下所示:

Array
(
    [2010091907] => Array
        (
            [home] => Array
            (
                [score] => Array
                (
                        [1] => 7
                        [2] => 17
                        [3] => 10
                        [4] => 7
                        [5] => 0
                        [T] => 41
                    )

                [abbr] => ATL
                [to] => 2
            )

        [away] => Array
            (
                [score] => Array
                    (
                        [1] => 0
                        [2] => 7
                        [3] => 0
                        [4] => 0
                        [5] => 0
                        [T] => 7
                    )

                [abbr] => ARZ
                [to] => 2
            )

        [weather] => 
        [media] => Array
            (
                [tv] => FOX
                [sat] => 709
                [sathd] => 709
                [radio] => Array
                    (
                        [home] => 153
                        [away] => 90
                    )

            )

        [bp] => 13
        [yl] => 
        [qtr] => Final
        [down] => 0
        [togo] => 0
        [clock] => 00:26
        [posteam] => ARZ
        [note] => 
        [redzone] => 
        [stadium] => Georgia Dome
    )

我需要它是动态的并且出于测试目的,我需要能够通过以下方式调用它:

echo "Key: $key; Value: $value<br />\n";

稍后我将获取这些信息并将其放入 mysql 数据库中,但现在,我需要温习一下数组并弄清楚如何格式化数据。

如有任何帮助,我们将不胜感激。

php arrays iteration
1个回答
24
投票

哈姆雷特

But where was this?

马塞勒斯

My lord, upon the platform where we watch'd.

哈姆雷特

Did you not speak to it?

霍雷肖

My lord, I did;
But answer made it none: yet once methought
It lifted up its head and did address
Itself to motion, like as it would speak;
But even then the morning cock crew loud,
And at the sound it shrunk in haste away,
And vanish'd from our sight.

哈姆雷特

'Tis very strange.

霍雷肖

As I do live, my honour'd lord, 'tis true;
And we did think it writ down in our duty
To let you know of it.

哈姆雷特

Indeed, indeed, sirs, but this troubles me.
Hold you the watch to-night?

马塞勒斯·贝尔纳多

We do, my lord.
© www.soinside.com 2019 - 2024. All rights reserved.