php find differences in multi dimensional arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • trpost@gmail.com

    php find differences in multi dimensional arrays

    I am looking for a way to find the differences between 2
    multidimensiona l 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) "WORKSTATIO N1"
    ["Category_C ode"]=>
    string(5) "WOR19"

    [1]=>
    array(6) {
    ["Category"]=>
    string(11) "WORKSTATIO N2"
    ["Category_C ode"]=>
    string(5) "WOR19"



    Array 2

    [0]=>
    array(6) {
    ["Category"]=>
    string(11) "WORKSTATIO N1"
    ["Category_C ode"]=>
    string(5) "WOR19"

    Resulting Array after identifying differences:

    [0]=>
    array(6) {
    ["Category"]=>
    string(11) "WORKSTATIO N2"
    ["Category_C ode"]=>
    string(5) "WOR19"

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

    Thanks

  • AlexVN

    #2
    Re: php find differences in multi dimensional arrays



    On Nov 3, 7:56 pm, trp...@gmail.co m wrote:
    I am looking for a way to find the differences between 2
    multidimensiona l 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) "WORKSTATIO N1"
    ["Category_C ode"]=>
    string(5) "WOR19"
    >
    [1]=>
    array(6) {
    ["Category"]=>
    string(11) "WORKSTATIO N2"
    ["Category_C ode"]=>
    string(5) "WOR19"
    >
    Array 2
    >
    [0]=>
    array(6) {
    ["Category"]=>
    string(11) "WORKSTATIO N1"
    ["Category_C ode"]=>
    string(5) "WOR19"
    >
    Resulting Array after identifying differences:
    >
    [0]=>
    array(6) {
    ["Category"]=>
    string(11) "WORKSTATIO N2"
    ["Category_C ode"]=>
    string(5) "WOR19"
    >
    So if any of the multidimentiona l 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

    Comment

    Working...