Oihana PHP

prepend.php

Table of Contents

Functions

prepend()  : array<string|int, mixed>
Prepends keys/values to the beginning of an array.

Functions

prepend()

Prepends keys/values to the beginning of an array.

prepend(array<string|int, mixed> $array, array<string|int, mixed> $before) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>

The target array.

$before : array<string|int, mixed>

Keys/values to prepend.

Tags
example
$data = ['name' => 'Alice'];
$result = prepend( $data , ['id' => 'A']);
// [ 'id' => 'A' , 'name' => 'Alice' ]
author

Marc Alcaraz (ekameleon)

since
1.0.8
Return values
array<string|int, mixed>

The merged array with $before keys first.


        
On this page

Search results