472,978 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,978 software developers and data experts.

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 3276


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James | last post by:
I see that variations on this question have appeared before but I'm still completely stumped. I'm developing an application with a fairly robust graphics component for 3D rendering. I've written...
2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
5
by: Cant Think Today | last post by:
I have multi-dimesional arrays that can be specifed by the user, e.g 1,2,3,4,5 1,2,3,4,5,6,7,8,9,10 1,2,3,4,5,6 I think a bit of code that will iterate over these arrays to print out the...
4
by: Richard Hayden | last post by:
Hi, Why does gcc (3.3.2) give me a 'initialization from incompatible pointer type' warning when compiling: int main(int argc, char** argv) { int testa; int** testp = testa; }
8
by: masood.iqbal | last post by:
All this time I was under the illusion that I understand the concept of multi-dimensional arrays well ---- however the following code snippet belies my understanding. I had assumed all along...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
4
by: Robert P. | last post by:
I can easily store a one-dimensional array in viewstate ( see Test1 ) If I try storing a multi-dimensional array in the viewstate it's crapping out on me when it goes to serialize the array (not...
1
by: xllx.relient.xllx | last post by:
Hi, I have two questions: 1.)Is it true that an rectangular array is really just an single dimensional array that lets itself be treated as a multi-dimensional array? For example the...
4
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.