filterLanguages.php
Table of Contents
Functions
- filterLanguages() : array<string, string|null>|null
- Filter an array or object of translations according to the given or available languages.
Functions
filterLanguages()
Filter an array or object of translations according to the given or available languages.
filterLanguages(array<string, string>|object|null $fields[, array<string|int, string>|null $languages = null ][, callable|null $sanitize = null ]) : array<string, string|null>|null
This helper transforms an input array/object from the client to prepare a multilingual (i18n) property. It keeps only string or null values, allows optional transformation or sanitization via a callback.
Parameters
- $fields : array<string, string>|object|null
-
Input array or object of translations.
- $languages : array<string|int, string>|null = null
-
Optional array of languages to filter the i18n definitions. If null, no filtering is applied.
- $sanitize : callable|null = null
-
Optional callback to transform or sanitize each value. Signature:
fn(string|null $value, string $lang): string|null
Tags
Return values
array<string, string|null>|null —Filtered translations matching the languages, or null if input is empty.