-1

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

Francois Deschenes
  • 24,816
  • 4
  • 64
  • 61
Dino
  • 1,445
  • 4
  • 24
  • 43

2 Answers2

2

Like this:

$array[0]['qty'] = 2;
deceze
  • 510,633
  • 85
  • 743
  • 889
0

Unless I'm missing something here, if you already know you want to update index 0:

$foo[0]['qty'] = 2;
Rob
  • 8,042
  • 3
  • 35
  • 37