在这里,我有我的阵列(在****
仅仅是字符串)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