PHP » GoLang |
login |
register |
about
|
array_count_valuesarray_count_valuesfunc ArrayCountValues(s []interface{}) map[interface{}]uint {
r := make(map[interface{}]uint)
for _, v := range s {
if c, ok := r[v]; ok {
r[v] = c + 1
} else {
r[v] = 1
}
}
return r
}
|