Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1736 | Replies: 1
![]() |
•
•
Join Date: Jul 2007
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Totally lost here. The output of one record in the array is posted below. I would like to get the sum of all the records in field [5] of the [Transporter Log].
I have tried various variations of the following (which I cut/paste from another thread). $subtotal allows returns '0'. I'm thinking I need to do nested loops to reach the [Transporter Log] array but not sure how to accomplish that. Any guidance would be much appreciated.
Here's the output of the first record in the array:
I have tried various variations of the following (which I cut/paste from another thread). $subtotal allows returns '0'. I'm thinking I need to do nested loops to reach the [Transporter Log] array but not sure how to accomplish that. Any guidance would be much appreciated.
$item = $datac; //results of mysql query
foreach($item as $key => $val){
$data[$key] = explode(",", $val);
}
for($k = 1; $k < count($item); $k++){
$subtotal[$k] = substr($data[$k][4],2);
}
foreach($subtotal as $val)
echo $val.' ';
echo '<br>Newest Sum: '.(array_sum($subtotal));Array
(
[0] => Array
(
[Transporter Log] => Array
(
[10] => Array
(
[2] => Array
(
[0] => 2007-07-10
)
[4] => Array
(
[0] => 1
)
[5] => Array
(
[0] => 1
)
[6] => Array
(
[0] => Shelter Wildlife Delivery
)
[17] => Array
(
[0] =>
)
[25] => Array
(
[0] =>
)
[uid] => 1
[mod_date] => 2007-07-26
[proxyid] => 1
[creation_date] => 2007-07-26
[creator_email] => admin@mydomain.com
)
)
)![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode