Skip to content

Instantly share code, notes, and snippets.

View thewebguy's full-sized avatar

Kevin Khandjian thewebguy

View GitHub Profile
@thewebguy
thewebguy / whichever.php
Created August 27, 2012 20:56
Function to get the first item that's set. I always find myself writing crap like this out a dozen times.
<?
/*
$first = null;
$second = 'ketchup';
$third = 'mustard';
$condiment = whichever($first, $second, $third); // $condiment == 'ketchup';
*/
function whichever() {
$options = func_get_args();