Tech Study

Write a PHP function to set union of two arrays

Introduction

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

Write a PHP function to set union of two arrays
Write a PHP function to set union of two arrays

TaggedWrite a PHP function to set union of two arrays

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more