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);
}
?>