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? Quote 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']; Quote 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!!!!! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.