php - Problems with mutiple array in foreach loops -
this first question here dont know normal style.
i have problem multiple arrays. arrays sorted way:
array ( [count] => 2 [gebruikerdata] => array ( [gebruiker1] => array ( [merken] => array ( [0] => merk1 [1] => merk10 [2] => merk19 ) [loginnaam] => testfasdfasd [geslacht] => man [persoonlijkheidstype] => test [beschrijving] => fasdfasdfasd [gebruikerid] => 19 [leeftijd] => 21 ) [gebruiker2] => array ( [merken] => array ( [0] => merk1 [1] => merk9 [2] => merk36 ) [loginnaam] => test1233 [geslacht] => man [persoonlijkheidstype] => test [beschrijving] => safasfd [gebruikerid] => 20 [leeftijd] => 21 ) ) )
i need retrieve information in array. there can many fields gebruiker(number) database output, tried use multiple foreach loops in eachother. problem is not possible use key 1 foreach loop index in foreach loop this:
foreach ($gebruikerdata $key => $value) { foreach ($key $key2 => $value2) { echo $key2; } }
does have idea how retrieve information array? or if use own way slight change?
try this
foreach ($gebruikerdata $key => $value) { if(is_array($key)) { foreach ($key $key2 => $value2) { if(is_array($key2)) { foreach($key2 $key3=>$value3) echo $key3.'-'.$value3; } else echo $key2.'-'.$value2; } } else echo $key.'-'.$value; }
check $key "array or not" each time,if array fo loop orelse echo directly
Comments
Post a Comment