<分区>
我有两个数组,它们是从两个 sql 查询生成的,分别是 $array_1 和 $array_2。都包含 [0] 个索引。我想用索引 [0]、[1] 等等来加入它们......所以任何人都可以帮助我如何在 php 中连接两个数组
<分区>
我有两个数组,它们是从两个 sql 查询生成的,分别是 $array_1 和 $array_2。都包含 [0] 个索引。我想用索引 [0]、[1] 等等来加入它们......所以任何人都可以帮助我如何在 php 中连接两个数组
最佳答案
array_merge — Merge one or more arrays
描述
array array_merge ( array $array1 [, array $... ] )
Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.
If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.
Values in the input array with numeric keys will be renumbered with incrementing keys starting from zero in the result array.
压缩数组:
如果您希望 [0]
为 array1[0]
并且 [1]
为 array2[0]
等,你可以压缩数组;
关于php - 如何在php中连接两个数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43318013/