how to compare two matrices and bring the different values?

1

I'm trying to make the schematic create a loop from 1 to 70 for example

In the database will return

1 10 11 20 39 50 67 69

From 1 to 70 only everything will go, it will only bring some numbers between 1 and 70.

I'm trying to create a loop using the from 1 to 70 and compare with the values shown above that returns from the bank, I need to display on the screen the values from 1 to 70 that does not have in the database, ie, which does not have Would it be possible for the bank to do this?

Follow the code:

$aleatorio = rand(1, 70);
echo $aleatorio."<br>";
$recorte = $valor."_".$aleatorio;


$query = mysqli_query($con,"select material_name_crop from qe.etiquetas_recortadas_aoi where material_name_crop = '$recorte' and line = '$pkg' and brand = '$brand'") or die("erro na query");
$rows = mysqli_num_rows($query);
if($rows < 1){
    echo $recorte." - ".$pkg." - ".$brand." S";
}else{
    $pesq = mysqli_query($con,"select material_name_crop from qe.etiquetas_recortadas_aoi where material_name_crop like '%$valor%' and line = '$pkg' and brand = '$brand'") or die("erro na query");
    $total = mysqli_num_rows($pesq);
    echo "Total ".$total."<br><hr>";
    $count = 0;
    while($recorte = mysqli_fetch_array($pesq)){
        $count = $count+1;
        $content = explode("_",$recorte[0]);
        $t = $content[1];

        //print_r($content);
        for($i=0;$i<=70;$i++){

            $j[] = $i;
            //echo $j[$i];
            $result = array_search($j[$i], $content[1]);
            echo $result;

    //      echo array_diff($val)."  -   ";
        }
        echo "<br>".$count." - ".$content[1]."      /       ";

        //print_r($j);


    }
        echo "<br>".$count." - ".$content[1]."      /       ";

        //print_r($j);


    }
    //echo $recorte[0]." - ".$pkg." - ".$brand." N";
}
    
asked by anonymous 04.04.2018 / 12:24

1 answer

0

You can use the in_array function, where it will check if the value is not within array (in your case, it would be the information coming from the bank).

// Armazena os dados vindo do banco em um array como este
$array_banco = array(1, 4, 7, 8, 2, 90);

for($i = 1; $i <= 70; $i++) {
   // Checa se o valor do for nao esta dentro do array
   if(!in_array($i, $array_banco)) {
        echo $i . ' nao esta dentro do array';
   }
}
    
04.04.2018 / 14:53