doukenqiong0588
2015-08-09 08:49
浏览 37
已采纳

Foreach多维数组

I have the following output created from a PHP script I have created:

Array
(
[cage] =>  OK
[logicaldrive] => Array
    (
        [logicaldrive 1] => Array
            (
                [size] => 2.7 TB
                [raid] => RAID 1
                [status] => OK
            )
    )

[physicaldrive] => Array
    (
        [logicaldrive 1] => Array
            (
                [physicaldrive 2I:1:1] => Array
                    (
                        [bay] => port 2I:box 1:bay 1
                        [type] => SATA
                        [size] => 3 TB
                        [status] => OK
                    )

                [physicaldrive 2I:1:2] => Array
                    (
                        [bay] => port 2I:box 1:bay 2
                        [type] => SATA
                        [size] => 3 TB
                        [status] => OK
                    )
            )

    )

I would like to be able to format this data into a table, I have tried but unable to run a foreach loop on sections of the array, for example if I want a table to have the information from:

[logicaldrive] => Array
    (
        [logicaldrive 1] => Array
            (
                [size] => 2.7 TB
                [raid] => RAID 1
                [status] => OK
            )

    )

I can't work out how to get the values of size, raid, status without knowing the key (logicaldrive 1) which depending on the system that the code has run on will be different each time.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题