$cartItemsArray = ["", "1", "2", "3", "3", "4", "2", "3"];
for ($i = 0; $i < count($cartItemsArray); $i++) {
echo $cartItemsArray[$i] . "<br />";
}
Here $cartItemsArray
is an array of some id's. I want to count the occurences of every element and save it in an array.
I want output like below:
Array = [1:"1", 2:"2", 3:"3", 4:"1"];
I want to save these array.