0

I have a MD Array, which I need to run a function on to return a result. To put it into context, its 5 servers with 1-3 hard drives that gets available remaining space.

$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")
);

It needs to loop through each server, then each hard drive to return the available space. The function to do that is under control, but the loop based on the above array is where I am stuck.

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 に答える