PHP Version
4.0.1+
/* Comparing indexed arrays */

$index_array1 = [1, 2, 3, 4, 5]; // Base array for comparison
$index_array2 = [2, 3, 4, 6, 7];

$index_unique_value = array_intersect($index_array1, $index_array2);

print_r($index_unique_value);
Output
/* Comparing associative arrays */

$assoc_array1 = [  // Base array for comparison
    'a' => 'apple',
    'b' => 'banana',
    'c' => 'carrot',
    'd' => 'date'
];

$assoc_array2 = [
    'x' => 'carrot',
    'b' => 'grape',
    'y' => 'apple'
];

$assoc_unique_value = array_intersect($assoc_array1, $assoc_array2);

print_r($assoc_unique_value);
Output
/* Comparing an indexed array with an associative array */

$arr_idx = ['a', 'b', 'c'];  // Base array for comparison

$arr_assoc = [
    'x' => 'b',
    'y' => 'c',
    'z' => 'd'
];

$assoc_unique_value = array_intersect($arr_idx, $arr_assoc);

print_r($assoc_unique_value);
Output
array_intersect(array $array_1, $array_2, $array_3, ...): array
$array1 = [1, 2, 3, 4, 5];
$array2 = [6, 7];

$result = array_intersect($array1, $array2);
print_r($result); // Array ( )
$array = [1, 2, 2, 3, 4, 4, 5];

$intersect = array_intersect($array);
print_r($intersect);
// As of PHP 8.0.0, it is possible to pass only a single array
/* Output:
	Array
	(
	    [0] => 1
	    [1] => 2
	    [2] => 2
	    [3] => 3
	    [4] => 4
	    [5] => 4
	    [6] => 5
	)
*/
$array = [1, 2, 2, 3, 4, 4, 5];

$counts = array_count_values($array);
$duplicates = array_filter($counts, function($count) {
    return $count > 1;
});

print_r(array_keys($duplicates)); // Array ( [0] => 2 [1] => 4 )
$array1 = ['a' => 1, 'b' => 2, 'c' => 3];
$array2 = ['x' => 1, 'y' => 2, 'z' => 3];

$result = array_intersect($array1, $array2);
print_r($result); // Output: Array ( [a] => 1 [b] => 2 [c] => 3 )
$array1 = [1, 2, '3'];  // '3' is a string
$array2 = [1, 2, 3];    // 3 is an integer

$result = array_intersect($array1, $array2);

print_r($result); // Output: Array ( [0] => 1 [1] => 2 [2] => 3 )
$userIdsFromDatabase = [1, 2, 3, 4, 5];
$selectedUserIds = [2, 4, 6, 8, 10];

$commonUserIds = array_intersect($userIdsFromDatabase, $selectedUserIds);
print_r($commonUserIds); // Array ( [1] => 2 [3] => 4 )
$submittedTags = ['php', 'javascript', 'html'];
$allowedTags = ['html', 'css', 'javascript', 'python'];

$validTags = array_intersect($submittedTags, $allowedTags);
print_r($validTags); // Array ( [2] => javascript [1] => html )
$adminPermissions = ['read', 'write', 'delete', 'update'];
$userPermissions = ['read', 'write'];

$allowedPermissions = array_intersect($adminPermissions, $userPermissions);
print_r($allowedPermissions); // Array ( [0] => read [1] => write )
$availableProducts = ['product1', 'product2', 'product3', 'product4'];
$selectedProducts = ['product2', 'product4', 'product5'];

$inStockProducts = array_intersect($availableProducts, $selectedProducts);
print_r($inStockProducts); // Array ( [1] => product2 [3] => product4 )