I would like to sort the following names
Array ( [Jessie] => 2 [Sarah] => 3 [Simon] => 2 [John] => 2 [Kevin] => 1 [Canvasser] => 8 [canvasser] => 11 )
based on their respective values
I printed the names using the following function
// get canvasser individual names and count houses canvassed foreach ($canvassers as $key => $value) { // Add to the current group count if it exists if ( isset( $canvasser_counts[$value] ) ) { $canvasser_counts[$value]++; } // or initialize to 1 if it doesn't exist else { $canvasser_counts[$value] = 1; } } print_r($canvasser_counts);
where $ canvassers just contained all the names, for example.
$canvassers = array('Jessie', 'Simon', 'Jessie')
Any help would really be appreciated, I spent so long on it, but can't figure out how to sort the array correctly.
source share