Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted
foreach ($array as $server => $disks) {
    print $server .' has the following disks:';
    foreach ($disks as $disk => $avalable_space) {
        print $disk .' has '. $available_space . 'available space';
    }
}
share|improve this answer
    
Thanks dude. Perfect. –  Rik Mar 6 '13 at 23:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.