Im trying to get a count in a foreach
like this
in the array
Item 1
Item 1
Item 2
Item 3
Item 3
Item 3
Item 3
Now these items comes from an explode
$likes = explode(',', $user_likes);
then i have
foreach($likes as $like){
echo $like.'<br>';
}
What i want as output is
item 1 (2)
item 2 (1)
item 3 (4)
So no double items but with how many times that item is in the array
Do
If you want it to be formatted like item 1 (2) item 2 (1), etc, do the following: