I have 2 arrays - one is hard coded and the other is data retrieved from a database. I am trying to merge them but I'm having unexpected results.
This is the first array:
$base_image_array = [
["product_image_one" => ""],
["product_image_two" => ""],
["product_image_three" => ""],
["product_image_four" => ""]
];
This is the second array:
$db_product_images = [
["product_image_one" => "../wp-content/themes/dosco/images/products_images/355_product_image_one.jpg"],
];
However, when I try array_merge($base_image_array, $db_product_images)
, I get 5 rows and the produce_image_one
occurs more than once.
What I want to achieve is this:
[
['product_image_one' => '../wp-content/themes/dosco/images/products_images/355_product_image_one.jpg'],
['product_image_two' => ''],
['product_image_three' => ''],
['product_image_four' => '']
]
I think the multidimensional nature of the arrays is confusing me.