在這裏,我有我的陣列(在****
僅僅是字符串)PHP數組元素插入並保持鍵
[m_timestamp] => ****
[n_id] => ****
[n_name] => ****
[n_material] => ****
[n_neck_finish] => ****
[n_weight] => ****
[n_height] => ****
[n_qty_p_ctn] => ****
[n_ctn_dimensions] => ****
[n_comment] => ****
[sha1] => ****
我怎麼可以插入另一個數組:
[n_group] => ****
[n_available] => ****
成原來的一個,這樣它看起來像:
[m_timestamp] => ****
[n_id] => ****
[n_name] => ****
[n_group] => **** //inserted
[n_available] => **** //inserted
[n_material] => ****
[n_neck_finish] => ****
[n_weight] => ****
[n_height] => ****
[n_qty_p_ctn] => ****
[n_ctn_dimensions] => ****
[n_comment] => ****
[sha1] => ****
我知道在哪裏插入T中的鍵值他數組(在這種情況下:n_name
)
我做了什麼:
$pos = intval(array_search("n_name", $myarray))+1;
array_splice($myarray, $pos, 0, $insertedarray);
,但它並沒有把$insertedarray
得當,它會將此[0]=>null
在我指定的
怎能位置我解決這個問題?
可能重複的[如何插入元件成陣列,以特定的位置?](http://stackoverflow.com/questions/3353745/how-to-insert-element-排列到特定位置) – 2012-08-05 10:22:57