Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/04/2005, 09:41
Avatar de Vaalegk
Vaalegk
 
Fecha de Ingreso: abril-2005
Mensajes: 154
Antigüedad: 19 años
Puntos: 2
Se me ocurre lo siguiente:
Código PHP:
<?php 
/*
Para chequear y crear un item con id $itemID:
*/
/*
Buscar en el $itemsEnCesta si hay algun item con id $itemID, 
si existe agregar cantidad.
IMPORTANTE: Asumiendo que cada pelicula tiene con Id diferente por formato, es decir si "Pelicula0" tiene un ID=001 para el formato VHS y otro ID para su formato DVD... si no hay que modificar mas el array
*/
if(array_key_exists($itemID,$itemsEnCesta))  //existe ?
// si, agregar uno mas 
  
$itemsEnCesta[$itemID]['cantidad']++;
}
else
{
//no existe, crear
   
$itemsEnCesta[$itemID]=array('cantidad'=>1,'formato'=>$formato);
}
?>