Re: Array Help Needed
- From: "J.O. Aho" <user@xxxxxxxxxxx>
- Date: Tue, 11 Nov 2008 06:53:24 +0100
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
.
- Follow-Ups:
- Re: Array Help Needed
- From: Jerry
- Re: Array Help Needed
- References:
- Array Help Needed
- From: Jerry
- Re: Array Help Needed
- From: J.O. Aho
- Re: Array Help Needed
- From: Jerry
- Array Help Needed
- Prev by Date: Re: Array Help Needed
- Next by Date: Web Application Engineer - Drupal, PHP, CSS, JavaScript, Postgresql
- Previous by thread: Re: Array Help Needed
- Next by thread: Re: Array Help Needed
- Index(es):
Relevant Pages
|