Comparing arrays
Posted: Tue Oct 04, 2016 2:19 pm
I'm trying to figure out the best way to compare two arrays.
My program needs to essentially do a "diff" on two arrays and report keys that are only found in Array A and only found in Array B, as well as values that are different between the two arrays.
Additionally,the arrays are nested with sub-arrays.
Can anybody point me at some sample code or some hints at the most efficient way of doing something like this? I thought about the possibility of converting the arrays to ordered text and then comparing lines like you would standard text, but maybe there is a different or better way.
Thanks in advance for any and all advice.
Jeffrey
My program needs to essentially do a "diff" on two arrays and report keys that are only found in Array A and only found in Array B, as well as values that are different between the two arrays.
Additionally,the arrays are nested with sub-arrays.
Can anybody point me at some sample code or some hints at the most efficient way of doing something like this? I thought about the possibility of converting the arrays to ordered text and then comparing lines like you would standard text, but maybe there is a different or better way.
Thanks in advance for any and all advice.
Jeffrey