所以我有两个数组,它们看起来像这样
第一个阵列:
Array (
[0] => Array (
[SteamId] => 123
)
[1] => Array (
[SteamId] => 330
)
[2] => Array (
[SteamId] => 234
)
[3] => Array (
[SteamId] => 790
)
[4] => Array (
[SteamId] => 665
)
)
第二个数组
Array (
[0] => Array (
[SteamId] => 124
)
[1] => Array (
[SteamId] => 0330
)
[2] => Array (
[SteamId] => 7234
)
[3] => Array (
[SteamId] => 0790
)
[4] => Array (
[SteamId] => 6665
)
)
所以我想做的是将它们互相添加,看起来像:
两个阵列:
Array (
[0] => Array (
[SteamId] => 123
)
[1] => Array (
[SteamId] => 330
)
[2] => Array (
[SteamId] => 234
)
[3] => Array (
[SteamId] => 790
)
[4] => Array (
[SteamId] => 665
)
[5] => Array (
[SteamId] => 124
)
[6] => Array (
[SteamId] => 0330
)
[7] => Array (
[SteamId] => 7234
)
[8] => Array (
[SteamId] => 0790
)
[9] => Array (
[SteamId] => 6665
)
)
但我目前无法让这两个数组在添加它们时重新索引它们的键。有人知道最好的方法吗?
答案 0 :(得分:1)
您可以使用array_merge()
$array3 = array_merge($array1,$array2);
print_r($array3);
输出: - https://eval.in/960203
如果案件无法使用 ,那么您需要array_merge()和array_values()一起使用
$array3 = array_values(array_merge($array1,$array2));
print_r($array3);
输出: - https://eval.in/960202
答案 1 :(得分:0)
只需使用PHP函数。
$results = array_merge($arr1,$arr2);