gtal3x Posted November 12, 2007 Share Posted November 12, 2007 can anyone help me extracting this array using foreach... $country_list = array( "1" => array("country" => "Afghanistan", "flag" => "af.png"), "2" => array("country" => "Albania", "flag" => "al.png"), "3" => array("country" => "Algeria", "flag" => "dz.png"), "4" => array("country" => "Andorra", "flag" => "ad.png"), I wont it to dispay: 1 Afganistan 2 Albania 3 Algeria..... and so on thanx in advance Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 http://us2.php.net/manual/en/function.in-array.php Quote Link to comment Share on other sites More sharing options...
gtal3x Posted November 12, 2007 Author Share Posted November 12, 2007 wat am i gonna read there? they dont explain anythin just give u examples, maybe if i was a big guru i would understand but am not btw i know how to extract keys and values from array, the problem here is that i got arrays inside array and am very confused Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 12, 2007 Share Posted November 12, 2007 well first of all it tells you how to extract the arrays variable and second of all you can teach yourself a little more about arrays if you would have a look at the manual. Quote Link to comment Share on other sites More sharing options...
kratsg Posted November 12, 2007 Share Posted November 12, 2007 You need to nest some foreach's... $country_list = array( "1" => array("country" => "Afghanistan", "flag" => "af.png"), "2" => array("country" => "Albania", "flag" => "al.png"), "3" => array("country" => "Algeria", "flag" => "dz.png"), "4" => array("country" => "Andorra", "flag" => "ad.png"), echo "<ol>\n"; foreach ($country_list as $index=>$array){ foreach ($array as $type=>$value){ if($type == "country"){echo "\t<li>".$value."</li>\n";} } } echo "</ol>"; Quote Link to comment Share on other sites More sharing options...
gtal3x Posted November 13, 2007 Author Share Posted November 13, 2007 cheers mate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.