我正在使用PHP 7.4.1.
当我跑步时:
<?php
$valArr = array();
$companyArr = array(
'name' => '',
'description' => '',
);
array_push($valArr,$companyArr);
$priceArr = array(
'currentPrice' => '',
'exch_name' => '',
'exch_symbol' => '',
);
array_push($valArr,$priceArr);
$otherTrxArr = array(
'otherTrx' => '',
);
array_push($valArr,$otherTrxArr);
print_r($valArr);
我得到:
Array
(
[0] => Array
(
[name] =>
[description] =>
)
[1] => Array
(
[currentPrice] =>
[exch_name] =>
[exch_symbol] =>
)
[2] => Array
(
[otherTrx] =>
)
)
然而,我只想得到:
Array
(
[name] =>
[description] =>
[currentPrice] =>
[exch_name] =>
[exch_symbol] =>
[otherTrx] =>
)
有什么建议如何array_push()正确使用仅添加新数组中的值吗?
largeQ
冉冉说