如何制作包含最大长度的组合数组?

I have these three arrays:

$arr1 = ['one', 'two', 'three'];
$arr2 = ['three', 'four'];
$arr3 = ['two', 'five', 'six', 'seven'];

And this is expected result:

/* Array
   (
       [0] => one
       [1] => two
       [3] => three
       [4] => four
       [5] => five
       [6] => six
       [7] => seven
   )

Here is my solution which doesn't work as expected:

print_r( array_unique( $arr1 + $arr2 + $arr3) );
/* Array
   (
       [0] => one
       [1] => two
       [2] => three
       [3] => seven
   )

How can I do that?

Use this:

array_unique(array_merge($arr1,$arr2,$arr3), SORT_REGULAR);

this will merge the arrays into one, then removes all duplicates

Tested Here

It outputs:

Array
(
    [0] => one
    [1] => two
    [2] => three
    [4] => four
    [6] => five
    [7] => six
    [8] => seven
)

I think this will work just fine

$arr1 = ['one', 'two', 'three'];
$arr2 = ['three', 'four'];
$arr3 = ['two', 'five', 'six', 'seven'];
$n_array = array_values(array_unique(array_merge($arr1 , $arr2 , $arr3)));
echo "<pre>";print_r($n_array);echo "</pre>";die;

Output is

Array
(
    [0] => one
    [1] => two
    [2] => three
    [3] => four
    [4] => five
    [5] => six
    [6] => seven
)

use array_merge then, array_unique

$arr1 = ['one', 'two', 'three'];
$arr2 = ['three', 'four'];
$arr3 = ['two', 'five', 'six', 'seven'];

print_r(array_unique (array_merge($arr1,$arr2,$arr3)));

Result

Array ( [0] => one [1] => two [2] => three [4] => four [6] => five [7] => six [8] => seven )

Just Do That.. use array_uniqe

Demo: https://eval.in/827705

<?php

    $arr1 = ['one', 'two', 'three'];
    $arr2 = ['three', 'four'];
    $arr3 = ['two', 'five', 'six', 'seven'];


    print_r ($difference = array_unique(array_merge($arr1, $arr2,$arr3)));
    ?>
<?php
    $arr1 = ['one', 'two', 'three'];
    $arr2 = ['three', 'four'];
    $arr3 = ['two', 'five', 'six', 'seven'];
    $merge_arr = array_merge($arr1,$arr2,$arr3);
    $unique_arr = array_unique($merge_arr);
    echo '<pre>';
        print_r($unique_arr);
    echo '</pre>';
?>

Output

Array
(
    [0] => one
    [1] => two
    [2] => three
    [4] => four
    [6] => five
    [7] => six
    [8] => seven
)