I am needing some help with comparing two arrays with array_diff. I need to find the unique data one one array when compared to another. For example array1 has 200 records and array2 has 250 records, I need to be able to find the difference between the two (the 50 left over when the two are compared). Here is the code I am using.
mysql_select_db($database_name, $queryOne);
$query_rsOld = "SELECT data FROM tableOne";
$rsOld = mysql_query($query_rsOld, $queryOne) or die(mysql_error());
$row_rsOld = mysql_fetch_assoc($rsOld);
$totalRows_rsOld = mysql_num_rows($rsOld);
$oldMls = array($row_rsOld['data']);
mysql_select_db($database_name, $queryTwo);
$query_rsNew = "SELECT data FROM tableTwo";
$rsNew = mysql_query($query_rsNew, $queryTwo) or die(mysql_error());
$row_rsNew = mysql_fetch_assoc($rsNew);
$totalRows_rsNew = mysql_num_rows($rsNew);
$newMls = array($row_rsNew['data']);
$difference = array_diff($newData, $oldData);
foreach ($difference as $key => $value) {
echo "<br />Key: $key; Value: $value\n"; }
When I execute the script above I get the following output:
Key: 0; Value: 107034
It is only pulling one record when there are at least 15 unique columns that need to be pulled. Any ideas on how to achieve this better or fix this script??