Skip to content

Instantly share code, notes, and snippets.

@tuandm
Created April 12, 2016 06:58
Show Gist options
  • Save tuandm/def7cf8b647e4fbcc00501ed7f7db009 to your computer and use it in GitHub Desktop.
Save tuandm/def7cf8b647e4fbcc00501ed7f7db009 to your computer and use it in GitHub Desktop.
Array Utils
class JT_Util_Array
{
/**
* Safety getting array's element. Return default value in case $key is not existed
*
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get(array $array, $key, $default = null)
{
return isset($array[$key]) ? $array[$key] : $default;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment