/**
* Check array for an key, return its value if found
*
* Search an array for a specific key, if found return the associated value,
* otherwise return the given default (if given, otherwise return a black string)
*
* @param array $array The array to search in
* @param string $key The key to search for
* @param any $default (OPTIONAL) The default to return if the key is not found (empty string when not provided)
*
* @return any The value in the array that belongs to this key or the default if not found.
*/
function getArrayValue($array, $key, $default='') {
return isset($array[$key]) ? $array[$key] : $default;
}
p.s. Voor zo'n kleine functie zou ik het 'Description' deel Search an array ... blank string) weglaten, maar ik heb het er voor de volledigheid even bij gezet.
In PHP is het gebruikelijk om een DocBlock te gebruiken om een functie van "commentaar" te voorzien. https://github.com/Corby7/educom-webshop-basis/blob/d790f5cc0a93b2101ab96454285ab7bcbea3cc20/index.php#L28-L31 wordt dan
Volledige beschrijving van DocBlocks