Creates a function which adds the defined values to the start of an array.
/**
* Returns a Closure for prepending a value to an array.
*
* @param mixed $value
* @return Closure(array<int|string, mixed>):array<int|string, mixed>
*/
Arrays\prepend(mixed $value): ClosureWhen Arrays\prepend() is called, it returns the following Closure which can be used like a regular function.
/**
* @param array<int|string, mixed> $array
* @return array<int|string, mixed>
*/
$function (array $data): arrayThis can be used to create a simple closure which can be used as a regular function.
// Create the closure that adds 'a' to the start of an array.
$addA = Arrays\prepend('a');
// Called as a function.
var_dump($addA(['b', 'c'])); // ['a', 'b', 'c']This can be called inline using currying.
// Adds `a` to the end of an array
var_dump(Arrays\prepend('a')(['b', 'c'])); // ['a', 'b', 'c']