PHP (codeigniter) で開発されたサイトがあり、同じ構造の配列をマージしたいと考えています。これは私の配列のコンストラクタです:
$first = array();
$first['hotel'] = array();
$first['room'] = array();
$first['amenities'] = array();
/*
Insert data into $first array
*/
$second = array();
$second['hotel'] = array();
$second['room'] = array();
$second['amenities'] = array();
/*
Insert data into $second array
*/
データを挿入した後、この配列をマージしたいのですが、問題はその中にサブ配列があり、そのような一意の配列を作成したいということです:
$total = array();
$total['hotel'] = array();
$total['room'] = array();
$total['amenities'] = array();
これはマージしようとしています:
$total = array_merge((array)$first, (array)$second);
この配列には $second 配列しかないのはなぜですか?