My PHP Script
$file_carrito=file("carrito.dat");
$x=0;
for($i=0;$i<sizeof($file_carrito);$i++)
{
$array_products_1[]=$file_carrito[$i];
$x++;
}
echo (array_count_values($array_products_1));
In this simple file .dat , store all products the user add , and count in each case total of products for each id and case
For example i can have into the file 5 ids for one product and other 4 for other product id , finally , this must count products with te same id stored into de dat file
For example : 5 pencils , 3 chairs , 2 tables , etc .....
The problem it´s no works : echo (array_count_values($array_productos_1));
content of carrito.dat :
p1
p1
p1
p3
p3
p3
p2
p2
p2
p1
p1
With this function of array i want get :
Product p1 ---- (5)
Product p2 ----- (3) , etc
Thank´s
carrito.dat
looks like – Sharlike Dec 12 '12 at 14:11