toAssociativeArray.php
Table of Contents
Functions
- toAssociativeArray() : array<string|int, mixed>
- Recursively converts an object (or array) into a full associative array.
Functions
toAssociativeArray()
Recursively converts an object (or array) into a full associative array.
toAssociativeArray(array<string|int, mixed>|object $document[, string|array<string|int, mixed>|object|null $encoder = null ][, bool $strict = false ]) : array<string|int, mixed>
This function handles nested objects, ensuring the entire array or object tree is converted.
Note that only public properties of the object will be included in the resulting array.
Parameters
- $document : array<string|int, mixed>|object
-
An array or object to convert to a deep associative array .
- $encoder : string|array<string|int, mixed>|object|null = null
-
Optional JSON encoder reference. This value is resolved into a callable using resolveCallable(). Supported forms:
- Closure or invokable object
- Callable array: [$object, 'method'] or ['Class', 'method']
- Named function: 'my_json_encoder'
- Static method string: 'MyClass::encode'
- null to use native json_encode()
The resolved callable must have the signature:
function(mixed $data): string - $strict : bool = false
-
If strict, not use json_encode but a standard loop.
Tags
Return values
array<string|int, mixed> —The resulting associative array.