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 Link to comment https://forums.phpfreaks.com/topic/76950-solved-extrack-array/ 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 Link to comment https://forums.phpfreaks.com/topic/76950-solved-extrack-array/#findComment-389622 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 Link to comment https://forums.phpfreaks.com/topic/76950-solved-extrack-array/#findComment-389627 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. Link to comment https://forums.phpfreaks.com/topic/76950-solved-extrack-array/#findComment-389629 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>"; Link to comment https://forums.phpfreaks.com/topic/76950-solved-extrack-array/#findComment-389631 Share on other sites More sharing options...
gtal3x Posted November 13, 2007 Author Share Posted November 13, 2007 cheers mate Link to comment https://forums.phpfreaks.com/topic/76950-solved-extrack-array/#findComment-390965 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.