vendredi 4 décembre 2020

Problems for join arrays

I have a problem but my brain doesn't give for more. I have this code

    $pedidosper=new PedidosPer();
    $salidapedidos=$pedidosper->salidaPedidos();
    $productosBloqueados= new PedidosPer();
    $productosBloqueados=$productosBloqueados->salidaPedidosBloqueados();

    $newArray = array();
    $newArray2 = array();

    for ($i=0; $i<count($salidapedidos); $i++) {
        for($j=0; $j<count($productosBloqueados); $j++) {

            if($salidapedidos[$i]->id_order == $productosBloqueados[$j]->idOrder) {
                $newArray[] = array($salidapedidos[$i]->id_order,$salidapedidos[$i]->name_shop,$salidapedidos[$i]->payment,$salidapedidos[$i]->customer_firstname,
                    $salidapedidos[$i]->customer_lastname,$salidapedidos[$i]->reference,$salidapedidos[$i]->total,$salidapedidos[$i]->fecha,$productosBloqueados[$j]->estado_id);
            }
        }

        $newArray2[] = array( 
                            $salidapedidos[$i]->id_order,
                            $salidapedidos[$i]->name_shop,
                            $salidapedidos[$i]->payment,
                            $salidapedidos[$i]->customer_firstname, 
                            $salidapedidos[$i]->customer_lastname,
                            $salidapedidos[$i]->reference,
                            $salidapedidos[$i]->total,
                            $salidapedidos[$i]->fecha,""
                        );
    }

I explain quickly, I am making a query to a database A and then I make the query to a database B. Database A and B share similar data and I am extracting the data to form a final array with the data that will be displayed on the screen.

As you can see this is the $newArray I make a comparison to create an array that has the data of the first "for" and add the data of the second "for" the idea is to complement the data. The $newArray this great has the data I need.

But now you will see the $newArray2 my idea is that $newArray2 has all the data except the ones that already exist in the $ newArray, at this moment, $newArray2 is placing data that already exists in $newArray but that I no longer want to have there. And the truth is that I don't know what the hell I'm missing. I would be very grateful if you could guide me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire