reorder.php
Table of Contents
Functions
- reorder() : array<string|int, mixed>
- Reorders an associative array by placing specified keys first, optionally sorting the rest.
Functions
reorder()
Reorders an associative array by placing specified keys first, optionally sorting the rest.
reorder(array<string|int, mixed> $array[, array<string|int, string> $firstKeys = [] ][, bool $sort = true ]) : array<string|int, mixed>
This function is useful for JSON serialization where key order matters (e.g., @type, @context first).
Parameters
- $array : array<string|int, mixed>
-
The input associative array.
- $firstKeys : array<string|int, string> = []
-
Keys that should appear first, in the given order.
- $sort : bool = true
-
Whether to sort remaining keys alphabetically (default: true).
Tags
Return values
array<string|int, mixed> —The reordered array.