0

i need your guide lines on how to differentiate between two associative array. One array coming from Database, and other one was input data, i want to compare these two array, which are not matching to know which input was edited.

Database

$databaseValues = [
    [color] => [
        [0]=> red,
        [1]=> blue,
        [2]=> green
    ],
    [regional]=> [
        [0] => International
        [1] => Domestic
        [2] => International
    ]
];

$postValues = [
    [color] => [
        [0]=> red,
        [1]=> blue,
        [2]=> blue 
    ],
    [regional]=> [
        [0] => International
        [1] => Domestic
        [2] => Domestic
    ]
];

How would which was changed by key and value, here you can clearly see post value changed green to blue

daremachine
  • 2,678
  • 2
  • 23
  • 34

1 Answers1

0

You can just loop through the post values, and on each iteration and compare that value to the corresponding value in the database.

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Russ J
  • 828
  • 5
  • 12
  • 24