Hello All,
I have 2 data sources. Data source A needs information to be updated on a regular basis. It receives it's updated information from data source B. There are many thousands of records involved here so I am trying to limit the amount of MySql queries as much as possible. I've managed to get both of these data sources into separate multi-dimensional arrays.
I need to write a function that will compare data source A with data source B and, in a new array, have the keys that need to be changed with only the values that are different.
Here is a visual:
Multi-dimensional array from datasource A
Array
(
["product_a"] =>
Array (
["description"]=>"Product A is Large"
["color"]=>"Red"
["quantity"]=>5
)
["product_b"] =>
Array (
["description"]=>"Product B is Small"
["color"]=>"Blue"
["quantity"]=>20
)
["product_c"] =>
Array (
["description"]=>"Product C has batteries included"
["color"]=>"Green"
["quantity"]=>7
)
)
Multi-dimensional array from datasource B
Array
(
["product_a"] =>
Array (
["description"]=>"Product A is Large"
["color"]=>"Yellow"
["quantity"]=>8
)
["product_b"] =>
Array (
["description"]=>"Product B is Small"
["color"]=>"Blue"
["quantity"]=>20
)
["product_c"] =>
Array (
["description"]=>"Product C is made of Wax"
["color"]=>"Green"
["quantity"]=>7
)
)
Here is what the new array should look like:
Array
(
["product_a"] =>
Array (
["color"]=>"Yellow"
["quantity"]=>8
)
["product_c"] =>
Array (
["description"]=>"Product C is made of Wax"
)
)
I know the function probably uses some form of the php built in array_diff function and I am sure there is recursion involved but I can't, for the life of me, figure out how to do this.
I am a beginner programmer so any help would be much appreciated.