audittr180 Posted May 29, 2011 Share Posted May 29, 2011 i have the following array $fruits = array("cherry" => "red", "apple" => "red", "kiwi" => "green", "strawberry" => "red", "pear" => "yellow", "melon" => "green", "grapes" => "green", "watermelon" => "red", "banana" => "yellow") using the array_count_values($fruits) i get Array ( => 4 => 3 [yellow] => 2 ) how can i asign the value of each key to a variable? Link to comment https://forums.phpfreaks.com/topic/237765-asign-a-variable-to-an-array-value/ Share on other sites More sharing options...
trq Posted May 29, 2011 Share Posted May 29, 2011 Just use the returned array. $arr = array_count_values($fruits); echo $arr['yellow']; Link to comment https://forums.phpfreaks.com/topic/237765-asign-a-variable-to-an-array-value/#findComment-1221830 Share on other sites More sharing options...
audittr180 Posted May 29, 2011 Author Share Posted May 29, 2011 thnx!!!!! Link to comment https://forums.phpfreaks.com/topic/237765-asign-a-variable-to-an-array-value/#findComment-1221832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.