Thanks Mordred,
That got it. I am not sure why, but the foreach loop has always been confusing to me. I do like using them better than for loops for messing with arrays.
Cheers!
J
Search found 8 matches
- Thu Apr 05, 2007 8:24 am
- Forum: PHP - Code
- Topic: Cannot create a new array key index
- Replies: 6
- Views: 954
- Wed Apr 04, 2007 12:57 pm
- Forum: PHP - Code
- Topic: Cannot create a new array key index
- Replies: 6
- Views: 954
Cannot create a new array key index
I am using the following code to iterate through a list of items: foreach ( $Cart["cart_content"] as $item) { $customerID = $item["customerID"]; if ($customerID == 0) { $sellerName="Company"; } else { $sellerName= getSellerNameFromID($customerID); } $item["seller&q...
- Tue Jan 30, 2007 2:52 pm
- Forum: PHP - Code
- Topic: need to split items in an array of an array according to...
- Replies: 9
- Views: 838
php arrays and smarty templates issue
I placed $sellers = array(); foreach( $cartcontent as $item ) { $seller = $item['seller']; unset($item['seller']); if (!array_key_exists($seller, $sellers)) { $sellers[$seller] = array(); } $sellers[$seller][] = $item; } inside of a function called get_order(); If I wanted to return an array called ...
- Thu Jan 25, 2007 3:04 pm
- Forum: PHP - Code
- Topic: need to split items in an array of an array according to...
- Replies: 9
- Views: 838
- Thu Jan 25, 2007 2:45 pm
- Forum: PHP - Code
- Topic: need to split items in an array of an array according to...
- Replies: 9
- Views: 838
What is the purpose of the following line of code:
Code: Select all
unset($item["seller"]);- Thu Jan 25, 2007 10:16 am
- Forum: PHP - Code
- Topic: need to split items in an array of an array according to...
- Replies: 9
- Views: 838
- Thu Jan 25, 2007 9:45 am
- Forum: PHP - Code
- Topic: need to split items in an array of an array according to...
- Replies: 9
- Views: 838
- Thu Jan 25, 2007 9:34 am
- Forum: PHP - Code
- Topic: need to split items in an array of an array according to...
- Replies: 9
- Views: 838
need to split items in an array of an array according to...
Hello, I am trying to take an array entitled cartcontent() which holds arrays of shopping cart items. For example: cartcontent[0] = product id=>, seller=>, name=>, quanity=> cartcontent[1]= " " " " I need to split cartcontent into separate arrays which all hold products that cont...