formatDocumentWith.php
Table of Contents
Functions
- formatDocumentWith() : array<string|int, mixed>|object
- Formats a document (array or object) using placeholders resolved from another source document.
Functions
formatDocumentWith()
Formats a document (array or object) using placeholders resolved from another source document.
formatDocumentWith(array<string|int, mixed>|object $target, array<string|int, mixed>|object $source[, string $prefix = '{{' ][, string $suffix = '}}' ][, string $separator = '.' ][, string|null $pattern = null ][, callable|null $formatter = null ][, bool $preserveMissing = false ]) : array<string|int, mixed>|object
Parameters
- $target : array<string|int, mixed>|object
-
The target document to format.
- $source : array<string|int, mixed>|object
-
The source document used for placeholder resolution.
- $prefix : string = '{{'
-
Placeholder prefix (default '{{').
- $suffix : string = '}}'
-
Placeholder suffix (default '}}').
- $separator : string = '.'
-
Separator used in nested keys (default '.').
- $pattern : string|null = null
-
Optional regex pattern to match placeholders.
- $formatter : callable|null = null
-
Optional custom formatter with signature:
function(string $value, array|object $source, string $prefix, string $suffix, string $separator, ?string $pattern, bool $preserveMissing): string
- $preserveMissing : bool = false
-
If true, preserves unresolved placeholders instead of removing them (default false).
Tags
Return values
array<string|int, mixed>|object —A new document with the same structure and class as $target
, where all string placeholders have been resolved using $source
.