You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$defaults = array_fill_keys(['username', 'email'], '');
# => creates a hash with passed keys having blank values
pulling values from hash and using blank defaults
functionpluck(array$keys, array$source) {
$defaults = array_fill_keys($keys, '');
return array_intersect_key($source, $defaults) + $defaults;
}
$data = pluck(['username', 'email', 'password'], $_POST);
# => $data will contain values for the keys, or blanks if not found
enforce a type on all array elements
declare(strict_types=1);
$input = ['one', 'two', 'three'];
$all_strings = (function (string ...$args) {
return$args;
})(...$input);
# => throws if an element is not a string
make a function only run once, and use cached result