Search found 8 matches

by jayreed21
Thu Apr 05, 2007 8:24 am
Forum: PHP - Code
Topic: Cannot create a new array key index
Replies: 6
Views: 954

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
by jayreed21
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...
by jayreed21
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 ...
by jayreed21
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

yea but why?
by jayreed21
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"]);
by jayreed21
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

Thanks for the quick response feyd! That makes a lot more sense now... You are a rock star!!
by jayreed21
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

How do I use seller element to index a new array? So I would do something like: foreach($cartcontent as &$value) { foreach($value as $key=>$value) { if ($key=="seller") { } } } I am having trouble understand how to even access the seller keys in an array of an array. Nor am I understan...
by jayreed21
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...