What is the purpose of using array_diff in PHP and how does it work?

The purpose of using array_diff in PHP is 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 operations based on those differences.

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

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

print_r($diff);
```

Output:
```
Array
(
    [0] => 1
    [1] => 2
)