如何找出多维数组之间的差异并打印出不同的值

时间:2017-02-09 09:29:50

标签: php jquery arrays multidimensional-array

我试图找出多维数组和尝试打印这些数组之间差异的区别。我正在尝试下面的代码,但没有获得所需的输出。

$("#display").click(function() {
  $.ajax({ //create an ajax request to load_page.php
    type: "GET",
    url: "index.php",
    dataType: "html", //expect html to be returned                
    success: function(response) {
      +
      //$("#responsecontainer").html(response); 
      //alert(response);
      //alert(subtractarrays(response,response));
      //var diff = $(response).not(response).get();

      $("#responsecontainer").html(response);

      var array_old = respose;
      var array_new = response;

      $.each(array_old, function(index, new_obj) {
        var old_id = new_obj['USER_ID'];
        var found = false;

        $.each(array_new, function(new_index, new_obj) {
          if (new_obj['USER_ID'] == old_id) {
            found = true;
          }
        });

        if (!found) {
          alert(old_id + " does not exist in array_new");
        } else {
          alert('No difference found');
        }
      });
    }
  });
});
});

0 个答案:

没有答案