src/ArrayLib.php
/**
     * Returns all the values that are in array1 and array2.
     * Relies on the values being integers or strings
     * Will only return a value once, even if it appears multiple times in the 
     * array.
     * Does not maintain indexes.
     * @param array $array1 - array of integers or strings to compare
     * @param array $array2 - array of integers or strings to compare
     * @return array - values that are in both arrays
     */
Returns all the values that are in array1 and array2.
Relies on the values being integers or strings
Will only return a value once, even if it appears multiple times in the
array.
Does not maintain indexes.
@param array $array1 - array of integers or strings to compare
@param array $array2 - array of integers or strings to compare
@return array - values that are in both arrays
Returns all the values that are in array1 and array2 . Relies on the values being integers or strings Will only return a value once even if it appears multiple times in the array . Does not maintain indexes . @param array $array1 - array of integers or strings to compare @param array $array2 - array of integers or strings to compare @return array - values that are in both arrays
public static function fastIntersect($array1, $array2)
    {
        $sharedValues = array();
        $flippedArray2 = array_flip($array2); 
        foreach ($array1 as $value)
        {
            if (isset($flippedArray2[$value])) 
            {
                $sharedValues[] = $value;
            }
        }
        return $sharedValues;
    }
public static function fastIntersect ( $ array1 , $ array2 ) { $ sharedValues = array ( ) ; $ flippedArray2 = array_flip ( $ array2 ) ; foreach ( $ array1 as $ value ) { if ( isset ( $ flippedArray2 [ $ value ] ) ) { $ sharedValues [ ] = $ value ; } } return $ sharedValues ; }
Returns all the values that are in array1 and array2.
Returns all the values that are in array1 and array2 .
# swaps indexes and values