prepare.php
Table of Contents
Functions
- prepare() : array<int|string, mixed>
- Prepares an array according to the given options: - REDUCE : filter/compress values - BEFORE : prepend keys - AFTER : append keys - FIRST_KEYS + SORT : reorder keys
Functions
prepare()
Prepares an array according to the given options: - REDUCE : filter/compress values - BEFORE : prepend keys - AFTER : append keys - FIRST_KEYS + SORT : reorder keys
prepare(array<int|string, mixed> $array[, array{after?: array, before?: array, defaults?: array, exclude?: array|null, firstKeys?: array, include?: array|null, sort?: bool, reduce?: bool|callable|array{clone?: bool, conditions?: callable|array|string|null, depth?: int|null, excludes?: array|null, recursive?: bool, removeKeys?: array|null, throwable?: bool}} $options = [] ]) : array<int|string, mixed>
This is typically used before serializing arrays for JSON output.
Parameters
- $array : array<int|string, mixed>
-
The input array.
-
$options
: array{after?: array
, before?: array = [], defaults?: array , exclude?: array |null, firstKeys?: array , include?: array |null, sort?: bool, reduce?: bool|callable|array{clone?: bool, conditions?: callable|array |string|null, depth?: int|null, excludes?: array |null, recursive?: bool, removeKeys?: array |null, throwable?: bool}} -
Options for transformation (see ArrayOption):
- 'reduce' => bool|array|callable
- 'before' => array
- 'after' => array
- 'firstKeys' => array
- 'sort' => bool
Tags
Return values
array<int|string, mixed> —The transformed array.