After searching and doing myself for a while, I decide to ask this question on Stackoverflow for advice from everyone's experiences.
What I'm trying to do is figuring out the efficient solution to check whether one array has same keys as another array, even the corresponded value is different.
Input array example,
Array(
['type'] => 'first',
['triggers'] => Array
(
['click'] => 'action1',
['push'] => 'action5',
['pull'] => Array
(
['event3'] => 'action6',
['event4'] => 'action7'
)
)
)
And here is the original array example which should be compared with,
Array(
['type'] => 'first',
['triggers'] => Array
(
['click'] => 'action1',
['push'] => 'action2',
['pull'] => Array
(
['event1'] => 'action3',
['event2'] => 'action4',
['event3'] => 'action6'
)
)
)
Above examples are in a similar(even the same) array structure, however, in the real service environment, all array data are dynamic.
What I need to know from the comparison is
- The value of ['trigger']['push'] will be changed
- The value of ['trigger']['pull']['event1'] will be changed
- The value of ['trigger']['pull']['event2'] will be changed
I know that is possible to check via foreach loop, but the real data is composed of greater dimensional array, and it may affect the performance.
Thanks !