我有一個數組:PHP如何爲數組設置鍵?
$a = array('color' => 'green', 'format' => 'text', 'link_url');
和另:
$b = array('zero', 'one', 'two', 'three', 'test' => 'ok', 'four');
而且隨着array_merge()我有一個這樣的數組:
Array
(
[color] => green
[format] => text
[0] => link_url
[1] => zero
[2] => one
[3] => two
[4] => three
[test] => ok
[5] => four
)
爲什麼PHP將陣列鍵上面?爲什麼不喜歡這樣的:
Array
(
[color] => green
[format] => text
[2] => link_url
[3] => zero
[4] => one
[5] => two
[6] => three
[test] => ok
[8] => four
)
雖然如此,這不是嚴格相關,因爲['用數字鍵輸入數組中的值將與遞增密鑰從零在結果array.'開始重新編號](HTTP ://www.php.net/manual/en/function.array-merge.php) – 2013-03-13 12:20:43