Repeated items within an array

Is there any function I can use to count repeated items within an array or should I use a variable?

I have the following array:


$arr = array(
    itemX,
    itemY,
    itemX,
    itemZ,
    itemY
);

I’m trying to print this:

ItemX no. 1
ItemY no. 1
ItemX no. 2
ItemZ
ItemY no. 2

array_count_values is what you need. Google it to get the page for it on the php manual.