php - how to get add total index in for loop? -
i want find out total amount of key in loop, example
'total' => array( 'a' => '12', 'b' => '4', 'c' => '6' ),
i getting info utilize loop
foreach($checkout $value =>$key) { ?> <tr> <td><?php echo $value ?></td> <td><?php echo $key ?> $/ month*</td> </tr> <?php }?> <?php echo $totalkey ?> $value , $ 1 $key
i want add together value of "a" "12", "b" "4" , on want total of a+b , on. result of these save in 1 vaiable, how can in php utilize each lop?
just add together total variable
$total = 0; foreach($checkout $value =>$key) { $total += $key; }
the array key-name stored in first variable in foreach. should
foreach($checkout $key => $value) {
php cakephp cakephp-1.3 cakephp-2.0
No comments:
Post a Comment