useful-api.org/utils/arrays.php
2023-11-24 10:01:17 +01:00

10 lines
250 B
PHP

<?php
function &array_get_or_add($needle, array &$haystack, $default=null) {
if (key_exists($needle, $haystack)) {
return $haystack[$needle];
} else {
$haystack[$needle] = $default;
return $haystack[$needle];
}
}