Add the potions returned by a for

0

Hi, I would like to add the potions returned by the for, it is not with count ()

              if (isset($_SESSION['carrito'])){
                  $datos = $_SESSION['carrito'];
                  for ($i=0; $i<count($datos); $i++) { 

                      echo count($datos);
                  }
                }
            ?>

In fact I want to add what the variable $ i brings me. It is a cart and not what I need to know are the total of the products that the user is agreagndo. know the total of the positions do not add the positions. of 0,1,2,3, = 4 positions.

    
asked by jorge enrique chan castillo 07.09.2018 в 19:22
source

1 answer

0

I would believe that what you are doing is entering the data array and adding what each position contains, and you do it with $ data [$ i]. for that you must create a variable outside the for and equal it to 0, then within the for pones:

Varnueva = Varnueva+$datos[$i];
    
answered by 07.09.2018 в 19:43