开发者

PHP Populating array with $variables

开发者 https://www.devze.com 2022-12-24 03:03 出处:网络
I\'m 开发者_JAVA百科trying to create a basic shopping cart, having an issue with the product page allowing users to add more items to their cart then are in stock (I have code in place to prevent this

I'm 开发者_JAVA百科trying to create a basic shopping cart, having an issue with the product page allowing users to add more items to their cart then are in stock (I have code in place to prevent this on the view cart page, just not the view product page)

This is what I have so far;

for ($i = 0; $i < $numItem; $i++) {
extract($cartContent[$i]);
$subTotal += $price * $cartQuantity;
$cartLimiter[$itemNo => $cartQuantity];

Using an array so the position number becomes the item number and the cart quantity becomes the assigned value, however it doesn't seem to like it and throws out on the bottom line of code:

Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting ']'

Thanks


Change this:

$cartLimiter[$itemNo => $cartQuantity];

to:

$cartLimiter[$itemNo] = $cartQuantity;


$cartLimiter[$itemNo] = $cartQuantity;


$cartLimiter[$itemNo] = $cartQuantity;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号