Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $primero = array(0,5,6,9,10,16);
- $segundo = array(1,2,3,7,8,12,13,19);
- $union = array();
- $i = 0;
- $j = 0;
- while ($i < count($primero) && $j < count($segundo)) {
- if ($i === count($primero)) {
- $union[] = $segundo[$j];
- $j++;
- continue;
- }
- if ($j === count($segundo)) {
- $union[] = $primero[$i];
- $i++;
- continue;
- }
- if ($primero[$i] < $segundo[$j]) {
- $union[] = $primero[$i];
- $i++;
- } else {
- $union[] = $segundo[$j];
- $j++;
- }
- }
- print_r($union);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement