Skip to content

Instantly share code, notes, and snippets.

@peterfox
Last active December 18, 2015 11:19
Show Gist options
  • Save peterfox/5774740 to your computer and use it in GitHub Desktop.
Save peterfox/5774740 to your computer and use it in GitHub Desktop.
A template of a function being applied to a CodeIgniter Helper file, the If statement checks if the function is already loaded, this is a good convention, it also means if you want to simulate a function not included in a current PHP version but is in a later one it'll be swapped in.
if ( ! function_exists('element'))
{
function element($item, $array, $default = FALSE)
{
if ( ! isset($array[$item]) OR $array[$item] == "")
{
return $default;
}
return $array[$item];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment