Lets say I have a multi-dimensional array like this:
Then I iterate over it like so:
I get exactly what I'm looking for, but is there a better way to go about this? It seems klugey.
I'm trying to use this approach on a separate problem where I want to fill an array with a module name and the file it will modify. The problem is that two modules could modify the same file and modules have multiple entries...so the repetition of both types of info prevent using either as an associative array key. My aim is to identify modules which will modify the same file and inform the user, but I'm finding it a bit difficult. Maybe I just can't get my brain around it today...I don't know.
Any suggestions on working with info like this? Array functions like array_intersect or array_diff won't do what I want and I'm banging my head on the table....
Code:
$file_mod_info[$mod_type][$mod_file_path][$index]='mod_string';
Code:
foreach ($file_mod_info as $mod_type => $mod_file_path_array) {
foreach ($mod_fil_path_array as $mod_file_path => $index_arrray) {
foreach ($index_array as $index => $mod_string) {
echo 'Mod Type: ' . $mod_type . "\n" .
'Mod File Path: ' . $mod_file_path . "\n" .
'Mod Index: ' . $mod_index . "\n" .
'Mod String: ' . $mod_string . "\n";
}
}
}
}
I'm trying to use this approach on a separate problem where I want to fill an array with a module name and the file it will modify. The problem is that two modules could modify the same file and modules have multiple entries...so the repetition of both types of info prevent using either as an associative array key. My aim is to identify modules which will modify the same file and inform the user, but I'm finding it a bit difficult. Maybe I just can't get my brain around it today...I don't know.
Any suggestions on working with info like this? Array functions like array_intersect or array_diff won't do what I want and I'm banging my head on the table....