Skip to content

Instantly share code, notes, and snippets.

@RoyalIcing
Last active August 29, 2015 14:02
Show Gist options
  • Save RoyalIcing/3725cc147261b7f70a21 to your computer and use it in GitHub Desktop.
Save RoyalIcing/3725cc147261b7f70a21 to your computer and use it in GitHub Desktop.
PHP burntCheck()
function burntCheck(&$valueToCheck, $default = null)
{
if (!empty($valueToCheck)) {
return $valueToCheck;
}
else {
return $default;
}
}

Instead of doing:

$name = !empty($json['name']) ? $json['name'] : null;

just do:

$name = burntCheck($json['name']);

And instead of:

$name = !empty($json['name']) ? $json['name'] : 'Unknown;

do:

$name = burntCheck($json['name'], 'Unknown');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment