src/Collections/Collection.php
public static function except($array1, $array2)
    {
        $result = [];

        foreach ($array1 as  $key => $value) {
            if (!static::contains($array2, $value)) {
                if (is_int($key)) {
                    static::add($array, $value);
                } else {
                    static::add($array, $value, $key);
                }
            }
        }

        foreach ($array2 as  $key => $value) {
            if (!static::contains($array1, $value) && !self::contains($result, $value)) {
                if (is_int($key)) {
                    static::add($array, $value);
                } else {
                    static::add($array, $value, $key);
                }
            }
        }

        return $result;
    }
public static function except($array1, $array2)
    {
        $result = [];

        foreach ($array1 as  $key => $value) {
            if (!static::contains($array2, $value)) {
                if (is_int($key)) {
                    static::add($array, $value);
                } else {
                    static::add($array, $value, $key);
                }
            }
        }

        foreach ($array2 as  $key => $value) {
            if (!static::contains($array1, $value) && !self::contains($result, $value)) {
                if (is_int($key)) {
                    static::add($array, $value);
                } else {
                    static::add($array, $value, $key);
                }
            }
        }

        return $result;
    }
public static function except ( $ array1 , $ array2 ) { $ result = [ ] ; foreach ( $ array1 as $ key => $ value ) { if ( ! static :: contains ( $ array2 , $ value ) ) { if ( is_int ( $ key ) ) { static :: add ( $ array , $ value ) ; } else { static :: add ( $ array , $ value , $ key ) ; } } } foreach ( $ array2 as $ key => $ value ) { if ( ! static :: contains ( $ array1 , $ value ) && ! self :: contains ( $ result , $ value ) ) { if ( is_int ( $ key ) ) { static :: add ( $ array , $ value ) ; } else { static :: add ( $ array , $ value , $ key ) ; } } } return $ result ; }
Distinct element between two array.

@param array $array1
@param array $array2

@return array
Distinct element between two array .