Getting the right value of a multidimentional array...
Posted: Mon Jun 29, 2009 7:13 am
Forgive me if I ask this in a stupid or naive way, but I'm having some problems with a multidimensional array that I'm working with and I can't seem to figure out how to pinpoint the correct sub-array using a foreach statement. The code I'm working with is below:
$questions has the following "sub arrays" in it: $text, $choices, and $answer. If $i is merely a counter variable (sentinel variable from a FOR statement), then how would I target or cycle through each value within the $choices sub array?
Code: Select all
foreach($questions[$choices][$i] as $key => $value){
echo $key.'<br />';
}