T
T
toaster_users2014-06-01 22:12:03
Arrays
toaster_users, 2014-06-01 22:12:03

How to count the number of repeated digits in an array, php?

Hello. Sorry for the possibly stupid question.
Started learning php.
There is an array with numbers, you need to find how many times each number occurs in this array.
Decided on this.

$array_n = array(1, 2, 3, 4, 5, 2, 4, 3, 5, 1, 2, 4, 5, 3, 5, 5, 3, 1);
$ac = array_count_values ($array_n);
print_r ($ac);

But it is also necessary to find out how many times the numbers 1 and 2, 1 and 3, 1 and 4, 1 and 5, 2 and 3, etc. occur in this array.
In this version, the numbers 1 and 2 occur 2 times, 3 and 4 - 3 times. - Is there a function like array_count_values ​​that will count the number of pairs of duplicate characters?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question