golang实现php的array_combine函数
func ArrayCombine(s1, s2 []interface{}) map[interface{}]interface{} {
if len(s1) != len(s2) {
panic("the number of elements for each slice isn't equal")
}
m := make(map[interface{}]interface{}, len(s1))
for i, v := range s1 {
m[v] = s2[i] }
return m
}
array_combine
(PHP 5, PHP 7)
– 创建一个数组,用一个数组的值作为其键名,另一个数组的值作为其值