zack_falcon
New member
if ($itemDBasename == "Flyff1")
{
global $itemName;
global $itemQuan;
$itemName[] = "Flyff20";
$itemQuan[] = $itemtoBuy;
}
In the sample code above, both $itemName and $itemQuan are values passed from a Session variable. It has no starting value. However, when I display the contents of the array, the first element is the word "Array" and the second element is always the last item I added to the array. I tried using the array_push() function, but the results are the same. I could never get the Array Count to go past 2.
Why does it overwrite the last element? And why is there an "Array" in the first element?
I'm sorry, perhaps a little more detail would be better. My website is an e-commerce project for school, and the arrays above are my primary concern in building my non-yet-existing shopping cart function. Basically, the user starts with NO items in his cart (empty array) and adds items as he/she browses the products (insert into array), and can view the Shopping cart anytime.
However, as stated above, the items are not inserted into the array (whether via array_push or my code above). Instead, the last item in the array is overwritten, so if I just added 2 pcs of Item A in my Cart, and added 1 pc of Item B, the array will only show 1 pc of Item B.
What I want to know, is that why is this happening?
Again, I'm sorry if this late addition caused any inconvenience.
{
global $itemName;
global $itemQuan;
$itemName[] = "Flyff20";
$itemQuan[] = $itemtoBuy;
}
In the sample code above, both $itemName and $itemQuan are values passed from a Session variable. It has no starting value. However, when I display the contents of the array, the first element is the word "Array" and the second element is always the last item I added to the array. I tried using the array_push() function, but the results are the same. I could never get the Array Count to go past 2.
Why does it overwrite the last element? And why is there an "Array" in the first element?
I'm sorry, perhaps a little more detail would be better. My website is an e-commerce project for school, and the arrays above are my primary concern in building my non-yet-existing shopping cart function. Basically, the user starts with NO items in his cart (empty array) and adds items as he/she browses the products (insert into array), and can view the Shopping cart anytime.
However, as stated above, the items are not inserted into the array (whether via array_push or my code above). Instead, the last item in the array is overwritten, so if I just added 2 pcs of Item A in my Cart, and added 1 pc of Item B, the array will only show 1 pc of Item B.
What I want to know, is that why is this happening?
Again, I'm sorry if this late addition caused any inconvenience.