code:-
<?php
function array_union($x, $y)
{
$aunion= array_merge(
array_intersect($x, $y),
array_diff($x, $y),
array_diff($y, $x)
);
return $aunion;
}
$p = array(1, 2);
$r = array(2, 3,4);
print_r(array_union($p, $r));
?>
function array_union($x, $y)
{
$aunion= array_merge(
array_intersect($x, $y),
array_diff($x, $y),
array_diff($y, $x)
);
return $aunion;
}
$p = array(1, 2);
$r = array(2, 3,4);
print_r(array_union($p, $r));
?>
output:-
array([0]=>1[1]=>2 [2]=>3 [3]=>4)
Post a Comment
If you have any doubts, Please let me know
Thanks!