Search code examples
phparraysupdating

How can I update a specific value in this array? (php)


I have the following array, $cart which is structured like so:

Array
(
    [0] => Array
        (
            [sku] => TEST1
            [size] => s
            [qty] => 1
        )

)

how can I update the qty to 2 directly using php and not using a foreach loop (nb. assume I have the index value (0) already).

Thanks


Solution

  • Like this:

    $array[0]['qty'] = 2;