Merge complex array php -
i have site developed in php (codeigniter) , want merge array same structure. constructor of array:
$first = array(); $first['hotel'] = array(); $first['room'] = array(); $first['amenities'] = array(); /* insert data $first array */ $second = array(); $second['hotel'] = array(); $second['room'] = array(); $second['amenities'] = array(); /* insert data $second array */ after insert data want merge array problem have subarray inside , want create unique array that:
$total = array(); $total['hotel'] = array(); $total['room'] = array(); $total['amenities'] = array(); this try merge:
$total = array_merge((array)$first, (array)$second); in array have $second array why?
use recursive version of array_merge called array_merge_recursive.
Comments
Post a Comment