468,136 Members | 1,453 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,136 developers. It's quick & easy.

php find differences in multi dimensional arrays

I am looking for a way to find the differences between 2
multidimensional arrays. I have found ways to do this based on 1 key,
but I want to be able to look at differences based on all keys:

For example:

Array 1

[0]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION1"
["Category_Code"]=>
string(5) "WOR19"

[1]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION2"
["Category_Code"]=>
string(5) "WOR19"

Array 2

[0]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION1"
["Category_Code"]=>
string(5) "WOR19"

Resulting Array after identifying differences:

[0]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION2"
["Category_Code"]=>
string(5) "WOR19"

So if any of the multidimentional array values are different, then
there isn't a match and the "record" is returned.

Thanks

Nov 3 '06 #1
1 3101


On Nov 3, 7:56 pm, trp...@gmail.com wrote:
I am looking for a way to find the differences between 2
multidimensional arrays. I have found ways to do this based on 1 key,
but I want to be able to look at differences based on all keys:

For example:

Array 1

[0]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION1"
["Category_Code"]=>
string(5) "WOR19"

[1]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION2"
["Category_Code"]=>
string(5) "WOR19"

Array 2

[0]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION1"
["Category_Code"]=>
string(5) "WOR19"

Resulting Array after identifying differences:

[0]=>
array(6) {
["Category"]=>
string(11) "WORKSTATION2"
["Category_Code"]=>
string(5) "WOR19"

So if any of the multidimentional array values are different, then
there isn't a match and the "record" is returned.

Thanks
Serialize elements of these two arrays and then use
http://php.net/array_diff.

Sincerely,
Alexander
http://www.alexatnet.com/ - PHP/ZendFramework/Ajax blog

Nov 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Cant Think Today | last post: by
4 posts views Thread by Richard Hayden | last post: by
1 post views Thread by xllx.relient.xllx | last post: by
4 posts views Thread by =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.