Re: Array Help Needed
- From: "Jerry" <jerroo@xxxxxxx>
- Date: Tue, 11 Nov 2008 17:34:39 -0800
"J.O. Aho" <user@xxxxxxxxxxx> wrote in message
news:6nskulFn2sbU1@xxxxxxxxxxxxxxxxxxxxx
Jerry wrote:
// pull subscriptions
$subscriptions = array();
$tot_sum = 0;
$add_this = false;
foreach ($order->products as $product) {
foreach ($product['attributes'] as $attribute) {
if ($attribute['option'] == 'Subscription') {
$subscriptions[] = $product;
if(isset($product['final_price']))
$add_this = true;
}
}
if($add_this) {
$tot_sum += $product['final_price'];
$add_this = false;
}
}
As a follow up question do you know how I could do the following:
Get all the [final_price] from the array that are from [attributes]
[option]
== 'Subscription' and add them into a total sum.
See above.
You need to make a check in the inner loop, and assing the value in the
outer,
in case the the attribute array is larger than one cell. In case it never
will, you could skip that array completely in your design.
--
//Aho
That is a nice solution! Thanks again J.O. Aho.
Best Regards, Jerry
.
- References:
- Array Help Needed
- From: Jerry
- Re: Array Help Needed
- From: J.O. Aho
- Re: Array Help Needed
- From: Jerry
- Re: Array Help Needed
- From: J.O. Aho
- Array Help Needed
- Prev by Date: Problems Uploading a File
- Next by Date: Re: Array Help Needed
- Previous by thread: Re: Array Help Needed
- Next by thread: Re: Array Help Needed
- Index(es):
Relevant Pages
|