0

我有一个 MD 数组,我需要在其上运行一个函数以返回结果。把它放在上下文中,它的 5 个服务器带有 1-3 个硬盘驱动器,可以获得可用的剩余空间。

$array = array(
"Server 1" => array("C" => "85791338496", "D" => "322119397376"),
"Server 2" => array("C" => "268327448576", "E" => "536733544448", "H" => "274874757120"),
"Server 3" => array("C" => "42947571712", "E" => "214744166400"),
"Server 4" => array("C" => "64317550592", "D" => "150320705536"),
"Server 5" => array("C" => "64317550592")
);

它需要遍历每个服务器,然后是每个硬盘驱动器以返回可用空间。执行此操作的功能受到控制,但基于上述数组的循环是我卡住的地方。

4

1 回答 1

5
foreach ($array as $server => $disks) {
    print $server .' has the following disks:';
    foreach ($disks as $disk => $avalable_space) {
        print $disk .' has '. $available_space . 'available space';
    }
}
于 2013-03-06T22:28:50.120 回答