Answer the question
In order to leave comments, you need to log in
How to find duplicate pairs of numbers in n php arrays?
Hello, can you please tell me how to find duplicate pairs of numbers in n arrays?
there are n arrays of the form:
$array_1 = array (1,2,3,4,5,8,9);
$array_2 = array (1,3,6,4,5,7,9);
....
$array_n = array (6,2,3,7,5,11,10);
Answer the question
In order to leave comments, you need to log in
You can use a hash, loop through the first array, take i and i + 1 numbers,
create a key for the hash "1-2" from it, check if there is a value in the hash with such a key, if not, then create and assign the value 0 , otherwise add 1. Further with other arrays similarly, using a single hash. At the end, print the contents of the hash.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question