<?php
function decartProductExclusive($one, $two)
{
$result = [];
for($i=0; $i<count($one); $i++)
{
for($j=0; $j<count($two); $j++)
{
if(!count(array_intersect((array)$one[$i], (array)$two[$j])))
{
$result[]=array_merge((array)$one[$i], (array)$two[$j]);
}
}
}
return $result;
}
function createAssociation()
{
$args = func_get_args();
if(!count($args))
{
return [];
}
$result = array_shift($args);
while($array=array_shift($args))
{
$result=decartProductExclusive($result, $array);
}
return $result;
}
$i[0] = ['a', 'b', 'c'];
$i[1] = ['d', 'e'];
$i[2] = ['a', 'b', 'c'];
$i[3] = ['d', 'e'];
$i[4] = ['f', 'g', 'h'];
$result = call_user_func_array('createAssociation', $i);
var_dump($result);
preferences:
37.66 ms | 402 KiB | 5 Q