我有一个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")
);
它需要遍历每个服务器,然后遍历每个硬盘驱动器以返回可用空间。这样做的函数是可控的,但基于上述数组的循环是我卡住的地方。
foreach ($array as $server => $disks) {
print $server .' has the following disks:';
foreach ($disks as $disk => $avalable_space) {
print $disk .' has '. $available_space . 'available space';
}
}