可以說我有兩個數組:array_merge兩個相同的陣列:你重置右側導致左側不露面
$a = array(
'product' => array(
'name' => "Some Product Name",
'description' => 'Some Product Description',
'productLink' => 'some.uri.url'
)
);
$b = array(
'product' => array(
'name' => 'Some Product Name',
'description' => 'Some other Description',
'price' => 10.95,
'tax' => 0.08,
)
);
我想這兩個陣列組合,但希望保持側$一個完整的名稱和說明。我認爲:
unset($b['product']['name']);
unset($b['product']['description']);
$c = array_merge($a, $b);
應導致:
$c = array(
'product' => array(
'name' => "Some Product Name",
'description' => 'Some Product Description',
'productLink' => 'some.uri.url',
'price' => 10.95,
'tax' => 0.08,
)
);
buuuut我看到這一點:
$c = array (
'product' => array (
'price' => 10.95,
'tax' => 0.08,
),
);
這是一個錯誤?