If I'm understanding you right, you want to add $data[0][0]['c'] and $data[1][0]['c'] to get 40, but what your code is actually doing is adding $data[1][0]['c'] plus $data[1][0]['c'] to give you 25 + 25 rather than 15 + 25. Personally, I'd go with a for loop rather than a foreach, if that's your goal.
For example: for($i=0; $i<count($data)-1; $i++) { if($i != 0) { $total = $data[$i][0]['c'] + $data[$i-1][0]['c']; } } Though I'm not quite clear on what it is you're doing... On Jul 23, 1:40 pm, mussond <[EMAIL PROTECTED]> wrote: > But <?php $total = $field[0]['c'] + $field[0]['c']; ?> doesn't give me > 40 but 50, so thats still not working. Does anyone know how I should > add fields from my array? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---