Merging two array elements into one array element in PHP
arrays, php
Solution
foreach ($origArray as $key => &$subArray)
$subArray += $arrayToBeAdded[$key];
Where `$origArray` is your array which is to be merged into and `$arrayToBeAdded` the array you merge into.
Problem
I want to merge two arrays into one array as follows, Array1: ``` Array ( [0] => Array ( [id] => 3 [sku] => KOG456 [cart_id] => 2 [name] => Young Money [slug] => young-money [route_id] => 47 [description] => This is test song [excerpt] => [saleprice] => 90.00 [related_products] => [images] => {"1c6b0883fc94c5f644497ec488cdf8cb":{"filename":"1c6b0883fc94c5f644497ec488cdf8cb.jpg","alt":"Test","caption":"","primary":true}} [seo_title] => [meta] => [enabled] => 1 ) ) ``` Array2: ``` Array ( [0] => Array ( [filename] => Beethovens_Symphony_No._9_(Scherzo).wma [title] => Young Money [size] => 599.26 ) ) ``` Expected array result is: ``` Array ( [0] => Array ( [id] => 3 [sku] => KOG456 [cart_id] => 2 [name] => Young Money [slug] => young-money [route_id] => 47 [description] => This is test song [excerpt] => [saleprice] => 90.00 [related_products] => [images] => {"1c6b0883fc94c5f644497ec488cdf8cb":{"filename":"1c6b0883fc94c5f644497ec488cdf8cb.jpg","alt":"Test","caption":"","primary":true}} [seo_title] => [meta] => [enabled] => 1 [filename] => Beethovens_Symphony_No._9_(Scherzo).wma [title] => Young Money [size] => 599.26 ) ) ``` How to merge these array elements into one array element ?