I have this multidimensional array (called $values):
Array
(
[0] => Array
(
[0] => 5
[1] => 2
[2] => 5
[3] => 6
)
[1] => Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
)
[2] => Array
(
[0] => 1
[1] => 2
[2] => 4
[3] => 5
)
[3] => Array
(
[0] => 9
[1] => 5
[2] => 3
[3] => 2
)
)
I want to calculate the diff
between every element (array) of this multidimensional array using array_diff
PHP function. The first thing I've thought is to split the multidimensional array into single arrays with this:
for($cnt = 0; $cnt < count($values); $cnt++){
for($cntB = 0; $cntB < 4; $cntB++){
${'arr'.$cnt}[] = $values[$cnt][$cntB];
}
}
After this I have several arrays called $arr1
, $arr2
, and so on. Since the dimension of the array $values
may vary (and it will) I can't find a way to pass all the generated single arrays to the function array_diff
,
Any thoughts?
Thanks in advance.