Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下数组,$cart其结构如下:
$cart
Array ( [0] => Array ( [sku] => TEST1 [size] => s [qty] => 1 ) )
如何使用 php 直接将 qty 更新为 2 而不是使用 foreach 循环(注意,假设我已经有了索引值(0))。
谢谢
像这样:
$array[0]['qty'] = 2;
除非我在这里遗漏了什么,否则如果您已经知道要更新索引 0:
$foo[0]['qty'] = 2;