Home Plugin documentation Hooks and functions Functions pip_array_count_values_assoc()
pip_array_count_values_assoc()
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don’t provide support for code customizations or 3rd party development.
Multi-dimensional version of PHP array_count_values() native function
/**
* Multi-dimension version of array_count_values
*
* @see array_count_values()
*
* @param $index
* @param $array
*
* @return array
*/
function pip_array_count_values_assoc( $array, $index ) {
$result = array();
foreach ( $array as $key => $value ) {
// Check if value is already in result array
if ( array_key_exists( $value[ $index ], $result ) ) {
// Increment counter
$result[ $value[ $index ] ] ++;
} else {
// New entry
$result[ $value[ $index ] ] = 1;
}
}
return $result;
}
Our home port
15 Rue Cavenne, 69007 Lyon
And from everywhere in the world thanks to Hangout and Skype !
Useful links