如何将具有多个索引的2个数组连接到1个数组中?我有这样的数组
Array
(
[0] => Array
(
[wd[wd5][amount]] => 1.00
[wd[wd5][address]] => 1BitcoinAddress
[wd[wd5][currency]] => BTC
)
[1] => Array
(
[wd[wd7][amount]] => 1.00
[wd[wd7][address]] => 1BitcoinAddress
[wd[wd7][currency]] => BTC
)
)
Run Code Online (Sandbox Code Playgroud)
我想将该数组转换/更改/合并为完全相同的东西
array(
'wd[wd5][amount]' => 1.00,
'wd[wd5][address]' => '1BitcoinAddress',
'wd[wd5][currency]' => 'BTC',
'wd[wd7][amount]' => 0.0001,
'wd[wd7][address]' => '1BitcoinAddress',
'wd[wd7][currency]' => 'BTC'
);
Run Code Online (Sandbox Code Playgroud)
我怎么做 ?
使用call_user_func_array和array_merge
<?php
$array = [
[
"[wd[wd5][amount]]" => 1.00,
"[wd[wd5][address]]" => "1BitcoinAddress",
"[wd[wd5][currency]]" => "BTC"
],
[
"[wd[wd7][amount]]" => 1.00,
"[wd[wd7][address]]" => "1BitcoinAddress",
"[wd[wd7][currency]]" => "BTC"
]
];
$result = call_user_func_array('array_merge', $array);
echo "<pre>";
print_r($result);
Run Code Online (Sandbox Code Playgroud)