我正在寻找将所有元素的所有数组的键更改为一个键的方法。最简单的方法来更改所有数组的键?
array(4) (
"a" => string(4) "foo1"
"b" => string(4) "foo2"
"c" => string(4) "foo3"
"d" => string(4) "foo4"
)
...到:
array(4) (
"a" => string(4) "foo1"
"a" => string(4) "foo2"
"a" => string(4) "foo3"
"a" => string(4) "foo4"
)
我宁愿代码没有任何循环。
在同一个数组中不能有两个相同的键。你会如何区分他们? – 2011-06-10 09:21:02
+1,您只需要数组的相反行为,其数组由唯一键标识。 – Benjamin 2011-06-10 09:22:26
我完全失败了。没有想到这一点。 – daGrevis 2011-06-10 09:27:52