1. Aarron Walter

  2. High Tech Gift Exchange With PHP

    Sep 27, 2006

    My family has a problem. Many of us live in different places across the US, and subsequently have a hard time honoring a long Christmas tradition of ours. Each year we draw names from a hat to determine who will be the recipient of our Christmas present. We started the tradition when I was just a kid because we didn’t have a lot of money to buy everyone a gift, but it has turned into our favorite part of Christmas. Everyone closely guards the secret of the name they have drawn, and there is often espionage involved to determine who might be buying you a gift.

    Since we all live in different cities now, a physical hat drawing won’t suffice anymore. To solve the problem I wrote a little PHP script that does the random drawing for us, and emails everyone the name they have drawn, preserving the secret.

    Take a look at the code here.

    The script creates two parallel arrays; one listing all gift exchange participant names, and the other listing their email address. Next, it runs a loop through the names array and generates a random number between 0 and the number of names, making the name selection. The trick is you should not be able to draw your own name or a name that has already been drawn. To prevent this, there is a while loop inside the name drawing loop that will redraw a name if the above criteria are not met (this was the trickiest part). Next you have to store the name drawn in an array that tracks who has already been selected so you don’t end up with someone getting more than one gift. Lastly, just send an email using the PHP Mailer class to the person telling them what name they have drawn.

    It works like a charm, and lets our family tradition continue for years to come!

  3. Designing for Emotion by Aarron Walter

    Designing for Emotion

    Walter’s approach is direct, rigorous, at times scientific and filled with practical insight and humor.

    Anthony Wing Kosner, Forbes

    buy the book

    The UX Sketchbook

    The UX Sketchbook

    Quickly create web site mockups with the UX Sketchbook. This new sketchbook has a 1-up web browser blueprint page, backed with a 2-up blueprint page.

    learn more

  4. Say Some Words