I am building an array with an unknown amount of levels:
$away_array [
0 => [1,2,3],
1 => [2,3,4],
2 => [3,4,5]
n..
]
What I would like to do is intersect the arrays.
PHP offers array intersect.
My question is: is it possible to use array intersect in the above example? Or is there an alternative option?
I am using PHP 7
EDIT - for clarity
As I have an unknown number of arrays that I wish to compare, I can not use array_interect in the usual manner:
result = array_intersect(array1,array2,array3);
Essentially I have an array of unknown number of arrays that I need to compare and return the common elements:
array = [ 0 => array1, 1 => array2, 2 => array3, 3 => array4, n.. ]
This would be entered:
$result = array_intersect(array1,array2,array3,array4,array...n)..
Obviously this is not possible...
So how can this be done recursively?