Skip to content

Instantly share code, notes, and snippets.

@hipsterjazzbo
Last active December 11, 2015 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hipsterjazzbo/4653971 to your computer and use it in GitHub Desktop.
Save hipsterjazzbo/4653971 to your computer and use it in GitHub Desktop.
<?
function print_if($string, $condition = null)
{
if (is_null($condition))
{
if (is_null($string) || empty($string))
{
return '';
}
if ($string === "0")
{
return "0";
}
if ($string === 0)
{
return 0;
}
return $string;
}
else if ($condition === TRUE)
{
return $string;
}
else
{
return '';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment