What is the function of array_diff() in PHP and how can it be used to compare two arrays?

The array_diff() function in PHP is used to compare two arrays and return the values from the first array that are not present in the second array. This function can be useful when you need to find the differences between two arrays and perform specific actions based on those differences.

```php
$array1 = [1, 2, 3, 4, 5];
$array2 = [2, 4, 6];

$diff = array_diff($array1, $array2);

print_r($diff);
```

In this code snippet, we have two arrays $array1 and $array2. We use the array_diff() function to compare $array1 with $array2 and store the differences in the $diff variable. Finally, we use print_r() to display the values in $diff, which will output [1, 3, 5] as these values are present in $array1 but not in $array2.