How can I go through all the records of two queries at the same time

0

How could I loop through all the records of 2 queries (at the same time) that are stored in 2 associative arrays (mysql_fecth_assoc) and compare them with the function array_diff (array1, array2).

I did it this way and only loads (and compares well) the values of both arrays in the first record of each one, then only loads the values of array1 and does not travel through array2.

<?php do {
$arr = array_diff($array1,$array2)
foreach ($arr as $value) {
        echo $value.' '.'<br>';}}
while($array1 = mysql_fetch_assoc($variable_query))?>
    
asked by Alejandro Martinez Alvaro 01.06.2018 в 13:43
source

1 answer

1

I think first we have to compare if the two arrays are the same size, then go through the key something like

for($x =0;$x < count($array1);$x++){
   if($array1[$x] != $array2){
      //todo
   }
}

or good, first what do you want to do, because array_diff only returns the value that was not found in the second array

    
answered by 04.06.2018 в 20:37