I’m trying to create a “secret santa” type of program that keeps track of who sent to who. I have a database that stores the shuffled sender and receiver id’s, but what I’m having a problem with is creating how to match next months senders and receivers. It needs to make sure that the sender is not sending to the same person twice in a row (or close together). I had the idea of looping through 4 arrays, $pastsenders, $pastreceivers, $currentsenders $currentreceivers, but i have no clue how to compare the two sets together to see if a match was made and if they do, to re-shuffle the current sender and receiver. Can anyone help?
Share
Use the sender’s name as the key, and use the receiver’s name as value.
To check, you just need to loop through all keys and see whether there is a key has the same value in this-month-array and next-month-array. If yes, then you need to rearrange next month’s list.