Getting values from associative array
arrays, php
Solution
I'd first transform `$m` to a simpler array with only one level:
$new_m = array();
foreach ($m as $item) {
foreach ($item as $key => $value) {
$new_m[$key] = $value;
}
}
Then you can use:
foreach ($options as $o) {
echo $new_m[$o];
}
Problem
I have the following main array called `$m` ``` Array ( [0] => Array ( [home] => Home ) [1] => Array ( [contact_us] => Contact Us ) [2] => Array ( [about_us] => About Us ) [3] => Array ( [feedback_form] => Feedback Form ) [4] => Array ( [enquiry_form] => Products ) [5] => Array ( [gallery] => Gallery ) ) ``` I have the values eg home, contact_us in a array stored $options , I need to get the values from the main array called $m using the $options array eg. If the $options array has value home, i need to get the value Home from the main array ($m) my code looks as follows ``` $c = 0; foreach($options as $o){ echo $m[$c][$o]; ++$c; } ``` I somehow just can't receive the values from the main array?