I have two arrays, looks like following
$array1 = array("color" => "red","size" => "32");
$array2 = array("color" => "blue","width" => "40");
and my php code is as follows
<?php
$array1 = array("color" => "red","size" => "32");
$array2 = array("color" => "blue","width" => "40");
$result = array_merge_recursive($array1, $array2);
echo json_encode($result);
?>
The output of this code is
{
color: [
"red",
"blue"
],
size: "32",
width: "40"
}
I want to get output like
{
color: [
"red",
"blue"
],
size: [
"32",
""
],
width: [
"",
"40"
]
}
How I can get this ? Please help me quickly.
Thanks in advance.