Can you provide an example of how to properly use the in_array function in PHP to check for duplicate values?

When working with arrays in PHP, you may need to check for duplicate values to avoid any inconsistencies in your data. One way to do this is by using the in_array function, which checks if a specific value exists in an array. By using this function, you can easily determine if there are any duplicates within an array.

// Example of using in_array to check for duplicate values in an array
$numbers = array(1, 2, 3, 4, 5, 2); // Array with duplicate value 2

if (in_array(2, $numbers)) {
    echo "Duplicate value found in the array.";
} else {
    echo "No duplicate values found in the array.";
}