<?php
/**
* Get X random tickets from total available tickets
*/
// Configuration
$totalTickets = 190000; // Total number of tickets available
$ticketsToGet = 5; // X number of tickets you want to get
// Step 1: Create array of all ticket numbers (1 to totalTickets)
$allTickets = range(1, $totalTickets);
// Step 2: Shuffle the array randomly
shuffle($allTickets);
// Step 3: Get first X tickets from shuffled array
$randomTickets = array_slice($allTickets, 0, $ticketsToGet);
// Display results
echo "Total Tickets: " . $totalTickets . "\n";
echo "Random Tickets Selected: " . $ticketsToGet . "\n";
echo "Ticket Numbers: " . implode(', ', $randomTickets) . "\n";
// Example Output:
// Total Tickets: 190000
// Random Tickets Selected: 5
// Ticket Numbers: 45123, 67890, 89234, 123456, 178901
?>
Have a question? We're here to help.
A few links that might point you in the right direction: