Creates a function which casts an array to a string using the defined glue.
Please note all arrays with keys will be converted to an indexed array/list.
/**
* Returns a Closure for zipping together 2 arrays
*
* @param array $additional The Array to zip with
* @param mixed $default The default value to use if the key does not exist in the additional array.
* @return Closure(array<int|string, mixed>): array<int|string, mixed>
*/
Arrays\zip(array $additional, mixed $default = null): ClosureWhen Arrays\zip() is called, it returns the following Closure which can be used like a regular function.
/**
* @param array<int|string, mixed> $array
* @return string
*/
$function (array $data): stringThis can be used to create a simple closure which can be used as a regular function.
// Create a closure that zips together 2 arrays with 'FALLBACK' as the default value.
$zip = Arrays\zip(['a', 'b', 'c'], 'FALLBACK');
// Called as a function.
var_dump($zip(['A', 'B'])); // [['a' , 'A'], ['b', 'B'], ['c', 'FALLBACK']]This can be called inline using currying.
// Zip together 2 arrays with 'FALLBACK' as the default value.
var_dump(Arrays\zip(['a', 'b', 'c'], 'FALLBACK')(['A', 'B']));
// [['a' , 'A'], ['b', 'B'], ['c', 'FALLBACK']]