belongs to collection: PHP array programs with examples
Write a PHP function to set union of two arrays
PHP is a server scripting language, and It is a powerful tool for making interactive and dynamic Web-pages. I have used WampServer 2.2 for following excercise..
<?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, 3, 4,5); $r = array(2, 3, 4, 5, 6,7,8); print_r(array_union($p, $r)); ?>
Result:
Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 1 [5] => 6 [6] => 7 [7] => 8 )
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
PHP is a server scripting language, and It is a powerful tool for making interactive and dynamic Web-pages. I have used WampServer 2.2 for following excercise..
Result:
Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 1 [5] => 6 [6] => 7 [7] => 8 )
need an explanation for this answer? contact us directly to get an explanation for this answer