1
votes

i have two arrays and i try to push them togther in one array but without key 0 like this :

 $array[] = $cart_info;
 $array[] = $new_cart_items;
Array
(
    [0] => Array
        (
            [A3ePDKuBTLF7hGOXJfWSI2os8RlYZQ69] => Array
                (
                    [id] => 189
                    [qty] => 1
                    [price] => 10.00
                    [name] => 1
                    [rowid] => A3ePDKuBTLF7hGOXJfWSI2os8RlYZQ69
                    [subtotal] => 10.00
                    [options] => Array
                        (
                            [unit_id] => 1
                            [Offer] => 0.00
                        )

                )

        )

    [1] => Array
        (
            [cXtxv82G0ROLrB64Vf3ZM7mNDdezTK5F] => Array
                (
                    [id] => 188
                    [qty] => 1
                    [price] => 10.00
                    [name] => 1
                    [options] => Array
                        (
                            [Offer] => 5.00
                            [unit_id] => 1
                        )

                    [rowid] => cXtxv82G0ROLrB64Vf3ZM7mNDdezTK5F
                    [subtotal] => 20
                )

        )

)

**and i want to change this structure to replace the key to be this hash ,also i don' know the hash because it is dynamic **

Array
(
    [aa7a2aa7357d176f175b5ac44397745b] => Array
        (
            [id] => 189
            [qty] => 1
            [price] => 10
            [name] => sfsfsf
            [options] => Array
                (
                    [Offer] => 0.00
                    [unit_id] => 1
                )

            [rowid] => aa7a2aa7357d176f175b5ac44397745b
            [subtotal] => 10
        )

    [c2832106fdb6a068de0a293fabdebc75] => Array
        (
            [id] => 188
            [qty] => 1
            [price] => 10
            [name] => Coffee of Excellence
            [options] => Array
                (
                    [Offer] => 5.00
                    [unit_id] => 1
                )

            [rowid] => c2832106fdb6a068de0a293fabdebc75
            [subtotal] => 10
        )

)
1
where is your PHP code?Rotimi
$array[] = $cart_info; $array[] = $new_cart_items;user1080247

1 Answers

0
votes

Try this:

 $array = array_merge($cart_info, $new_cart_items);

See also http://php.net/manual/ru/function.array-merge.php