Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Counting number of similar items in an array

0 views
Skip to first unread message

JustWondering

unread,
Dec 31, 2009, 2:24:23 PM12/31/09
to
$test = array (1, 2, 3, 3, 3, 3, 1, 2, 2, 1);

Does PHP have something that allows me to count the number of 1's, 2's
and 3's in $test?

Doug Miller

unread,
Dec 31, 2009, 2:26:24 PM12/31/09
to

array_count_values()

JustWondering

unread,
Dec 31, 2009, 2:33:20 PM12/31/09
to
On Dec 31, 11:26 am, spamb...@milmac.com (Doug Miller) wrote:

> In article <0b68695e-234b-4846-9a45-52b9d4883...@k17g2000yqh.googlegroups.com>, JustWondering <eastside...@gmail.com> wrote:
>
> >$test = array (1, 2, 3, 3, 3, 3, 1, 2, 2, 1);
>
> >Does PHP have something that allows me to count the number of 1's, 2's
> >and 3's in $test?
>
> array_count_values()

Thanks.

0 new messages