src/ArrayLib.php
public static function fastDiff($array1, $array2)
    {
        $missingValues = array();
        $flippedArray2 = array_flip($array2); # swaps indexes and values
       
        foreach ($array1 as $value)
        {
            if (!isset($flippedArray2[$value])) 
            {
                $missingValues[] = $value;
            }
        }
        
        return $missingValues;
    }
public static function fastDiff($array1, $array2)
    {
        $missingValues = array();
        $flippedArray2 = array_flip($array2); # swaps indexes and values
       
        foreach ($array1 as $value)
        {
            if (!isset($flippedArray2[$value])) 
            {
                $missingValues[] = $value;
            }
        }
        
        return $missingValues;
    }
public static function fastDiff ( $ array1 , $ array2 ) { $ missingValues = array ( ) ; $ flippedArray2 = array_flip ( $ array2 ) ; # swaps indexes and values foreach ( $ array1 as $ value ) { if ( ! isset ( $ flippedArray2 [ $ value ] ) ) { $ missingValues [ ] = $ value ; } } return $ missingValues ; }
Faster version of array_diff that relies on not needing to keep indexes
of the missing values
Compares values, but returns the indexes
@param array $array1 - array to compare
@param array $array2 - array to compare
@return array - values in array1 but not array2
Faster version of array_diff that relies on not needing to keep indexes of the missing values Compares values but returns the indexes