Re: Object Undefinded index
From: Al (php.newsgroups_at_allysays.com)
Date: 10/30/03
- Next message: John W. Holmes: "Re: [PHP] Undefined Index - is this how you "declare" get & post?"
- Previous message: ME: "Apache core dumps when started with php4_module on FreeBSD 5.1"
- In reply to: Steve Turner: "Object Undefinded index"
- Next in thread: Al: "Re: Object Undefinded index"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: php-general@lists.php.net Date: Thu, 30 Oct 2003 15:28:47 +1100
> foreach ($cart as $product_id => $quantity)
> {
> echo $product_id . "<br>" . $quantity;
> }
The way you are accessing the array is incorrect. The $items array is a
property of the Cart object. Since the Cart object may have many different
array properties, the foreach statement above has to be sepcific about which
array you want to iterate through.
So the correct code would be:
foreach ($cart->items as $product_id => $quantity)
{
echo $product_id . "<br>" . $quantity;
}
- Next message: John W. Holmes: "Re: [PHP] Undefined Index - is this how you "declare" get & post?"
- Previous message: ME: "Apache core dumps when started with php4_module on FreeBSD 5.1"
- In reply to: Steve Turner: "Object Undefinded index"
- Next in thread: Al: "Re: Object Undefinded index"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|