How can PHP be utilized to automate the process of assigning employees to different shifts based on their availability?

To automate the process of assigning employees to different shifts based on their availability using PHP, we can create a script that reads the availability of each employee and matches it with the available shifts. The script can then assign employees to shifts based on their availability and any set criteria.

// Sample code to automate the process of assigning employees to shifts based on availability

// Define employee availability
$employeeAvailability = [
    'Employee1' => ['Monday', 'Wednesday', 'Friday'],
    'Employee2' => ['Tuesday', 'Thursday'],
    'Employee3' => ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
];

// Define available shifts
$availableShifts = ['Morning Shift', 'Afternoon Shift', 'Night Shift'];

// Assign employees to shifts based on availability
foreach ($employeeAvailability as $employee => $daysAvailable) {
    $assignedShift = array_intersect($daysAvailable, $availableShifts);
    
    echo "$employee is assigned to: " . implode(', ', $assignedShift) . "\n";
}