我有这两个数组:PHP插入多维数组到另一个多维数组
Array
(
[InterfacedaRequisicaodePagamento] => Array
(
[0] => Array
(
[SequenciadoRegistro] => 15015
[CodigodaContadoDocumento] =>
)
)
)
和
Array
(
[InterfaceGrupoRequisicaodePagamento] => Array
(
[0] => Array
(
[CodigodoProjeto] =>
)
)
)
我需要的是的CodigodaContadoDocumento
项之后插入第二阵列第一个数组生成一个JSON字符串,但array_push
不起作用,并且在这种情况下我不知道如何使用array_splice
。
我使用
array_push($interfaceRequisicaoPagamento, $interfaceGrupoRequisicaodePagamento);
,结果如下:
Array (
[InterfacedaRequisicaodePagamento] => Array (
[0] => Array (
[SequenciadoRegistro] => 15015
[CodigodaContadoDocumento] =>
)
)
[0] => Array (
[InterfaceGrupoRequisicaodePagamento] => Array (
[0] => Array (
[CodigodoProjeto] =>
)
)
)
)
但我需要的是:
Array
(
[InterfacedaRequisicaodePagamento] => Array
(
[0] => Array
(
[SequenciadoRegistro] => 15015
[CodigodaContadoDocumento] =>
[InterfaceGrupoRequisicaodePagamento] => Array
(
[0] => Array
(
[CodigodoProjeto] =>
)
)
)
)
)
你能发布您的代码? 'array_push()'应该工作得很好。 – jeroen
请将预期结果添加到您的问题中。 (为什么没有人发布可复制数组?XD) – FirstOne
@jeroen我使用'array_push($ interfaceRequisicaoPagamento,$ interfaceGrupoRequisicaodePagamento);',并将结果如下: \t阵列 \t( \t \t [InterfacedaRequisicaodePagamento] =>数组 \t \t \t( \t \t \t \t [0] =>数组 \t \t \t \t \t( \t \t \t \t \t \t [SequenciadoRegistro] => 15015 \t \t \t \t \t \t [CodigodaContadoDocumento] => \t \t \t \t \t) \t \t \t) \t \t [0] =>数组 \t \t \t( \t \t \t \t [InterfaceGrupoRequisicaodePagamento] =>数组 \t \t \t \t \t( \t \t \t \t \t \t [0] =>数组 \t \t \t \t \t \t \t( \t \t \t \t \t \t \t \t [CodigodoProjeto] => \t \t \t \t \t \t \t) \t \t \t \t \t) \t \t \t) \t) –