What is the best approach to checking for duplicate time slots in a PHP application?

When working with time slots in a PHP application, the best approach to checking for duplicate time slots is to maintain a list of already added time slots and compare new time slots against this list before adding them. This can be done by storing time slots in an array or database table and checking for duplicates before inserting a new time slot.

// Sample code to check for duplicate time slots in a PHP application

// Assume $timeSlots is an array containing existing time slots
$newTimeSlot = "10:00 AM - 11:00 AM";

// Check for duplicate time slots
if (in_array($newTimeSlot, $timeSlots)) {
    echo "Duplicate time slot found!";
} else {
    // Add the new time slot to the list
    $timeSlots[] = $newTimeSlot;
    echo "Time slot added successfully!";
}