在PHP中實現集合的并集操作可以通過以下幾種方式:
$array1 = [1, 2, 3, 4];
$array2 = [3, 4, 5, 6];
$union = array_unique(array_merge($array1, $array2));
print_r($union);
$array1 = [1, 2, 3, 4];
$array2 = [3, 4, 5, 6];
$union = array_unique(array_merge($array1, $array2));
print_r($union);
$array1 = [1, 2, 3, 4];
$array2 = [3, 4, 5, 6];
$intersect = array_intersect($array1, $array2);
$union = array_unique(array_merge($array1, $array2, $intersect));
print_r($union);