Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deansatch's avatar

Preferred date, choose 3, system sorts out who goes when

Basically I am wanting to build something where there are events available each with 10 places available. Users can book a place but must choose their 3 most preferred dates. Then when registration closes, the system will work out who goes on what date to ensure there are no more than 10 per event.

Any ideas what the best route to take would be?

One big hurdle I can see is how could the system know if there are going to be too many people on one event. If for example 40 people happen to choose the same 3 there will be 10 people can't go any date.

0 likes
3 replies
martinbean's avatar

@deansatch Sounds like you need some validation to prevent your events from becoming over-subscribed in that case.

deansatch's avatar

Yeah I'm just trying to get my head around what logic/math would work out at what point an event is definitely oversubscribed

e.g. Lets say there are 5 events A,B,C,D&E. And 1 person limit on each

U= user

U1 chooses A B C
U2 chooses A B C
U3 chooses A B D

// at this point one is full but I don't know which one as it could be A or B

U4 chooses A B D

// Now we can definitely say A-D are full

// But if U4 did A D E instead still only one unknown is full

U4 chooses A D E
U5 chooses A B D //  all 5 are now full


So with that above how could I do that coding-wise?


//key = event date, val = max places
$events = [
   'a'=>1,
   'b'=>1,
   'c'=>1,
   'd'=>1,
   'e'=>1,
   'f'=>1,
];

$choices = [
   1 => 'a','b','c',
   2 => 'a','b','c',
   3 => 'a','b','d',
   4 => 'a','d','e',
   5 => 'a','b','d',
];

// How would I calculate from above to get this result
$fullEvents = ['a','b','c','d','e'];
$availableEvents = ['f'];

Please or to participate in this conversation.