How can PHP be used to dynamically display and reserve specific seat numbers for customers purchasing tickets?

To dynamically display and reserve specific seat numbers for customers purchasing tickets in PHP, you can create a system that checks the availability of seats and assigns a seat number to the customer upon purchase. This can be achieved by storing seat availability in a database or array, updating it when a seat is reserved, and displaying the available seats to the customer.

<?php

// Assume $availableSeats is an array containing available seat numbers
$availableSeats = [1, 2, 3, 4, 5];

// Simulate customer purchasing a ticket
$customerSeat = array_shift($availableSeats);

// Update available seats after reservation
// This step would typically involve updating a database or session variable
// For demonstration purposes, we will just remove the reserved seat from the array
echo "Customer reserved seat number: " . $customerSeat . "\n";

// Display updated available seats
echo "Available seats: " . implode(", ", $availableSeats);

?>