得到我的商品价格的总和

I know i should know this but i just can get it,

I need to get total price for this

    <?php

if (is_array(Yii::app()->session['cart']))
{
    $totalQuantity = 0;
    $totalPrice = 0;

    foreach ( Yii::app()->session['cart'] as $value) {
        $totalQuantity += $value['quantity'];
        $totalPrice += $value['price'];

?>
    <tr id="TDcartTable">
        <td class="docName">
          <?php echo $value['file']; ?>
        </td>
        <td>
            £ <?php echo number_format($value['price'], 2); ?>
        </td>
        <td>
           <?php echo $value['quantity']; ?>
        </td>
        <td>
            £ <?php echo number_format(($value['quantity'] * $value['price']), 2); ?>
        </td>

    </tr>
     <?php }
} ?>
    </tr>
    <tr>
        <td class="column-title">
        </td>
        <td class="column-title">
        </td>
        <td class="column-title">
        </td>
        <td class="column-title">
            <?php echo CHtml::encode(Yii::t('app', 'Total Quantity')); ?>: <?php echo $totalQuantity; ?>
        </td>
        <td class="column-title">
            <?php echo CHtml::encode(Yii::t('app', 'Total')); ?>: £<?php echo number_format($totalPrice, 2); ?>
        </td>
    </tr>

When i do it like this i get the total number of price, but what i need is total number of price (calculate with quantity), when i try to do it like this

foreach ( Yii::app()->session['cart_values'] as $value) {
        $totalQuantity += $value['quantity'];
        $itemTotal = number_format(($value['price'] * $value['quantity']), 2);
        $totalPrice += $itemTotal;

im geting some strange numbers.

Thanks for explanation.

number_format() produces a string.

Do that only when displaying the result of a calc, like you have in the HTML later in the code.

So change

$itemTotal = number_format(($value['price'] * $value['quantity']), 2);
$totalPrice += $itemTotal;

to

 $totalPrice += ( $value['price'] * $value['quantity'] );