Store array of a loop

0

I need to store the results of a series of different queries in mysql loop in one array to compare it with another and see the differences and delete what is left over.

Is there any way to do it?

At the moment I do not have any code except the query to mysql and the loop that I do with a foreach and in each loop changes the parameters of the search automatically with a Cartesian product.

if it's any good I put the code.

$UpTallicolor = CartesianProduct(array('tallas'=> $_POST['tallas'], 'color'=> $_POST['colores']));
    foreach($UpTallicolor as $DUptallicolor) {
        $CExisteArt = Consulta_Dinamica("Simple","*","Codigos","'que' = 'Codigo' AND 'id' = '".$_POST["nuevo"]."' AND '1'='".$DUptallicolor['tallas']."' AND '2'='".$DUptallicolor['color']."' ");
        } //cierro el foreach

The result would have to give me everything that is not in the generated array of the Cartesian product must be deleted from mysql.

I think that to compare the two resulting arrays I have to use a array_diff_assoc , would it be the form? Or just with array_diff ?

A thousand thanks to everyone for the help

    
asked by Killpe 06.01.2017 в 21:38
source

1 answer

1

You need to declare the variable that will hold the array to compare outside the loop and then fill your array inside the loop, finally compare what you need outside the loop:

$array_final = [];
foreach($UpTallicolor as $DUptallicolor) {
    $array_final[] = $valor_para_comparar;
}

$resultado = array_diff($array_final, $array_a_comparar);

print_r($resultado);

And so it returns the values that are not in both arrays ...

I hope you serve

    
answered by 06.01.2017 / 22:16
source