function FilterArray::removeEmptyStrings

Removes empty strings from an array.

This method removes all empty strings from the input array. This is particularly useful to preserve 0 whilst filtering other falsy values. The values are first cast to a string before comparison.

Parameters

array $value: The array to filter.

Return value

array The filtered array.

10 calls to FilterArray::removeEmptyStrings()
Connection::sqlFunctionLeast in core/modules/sqlite/src/Driver/Database/sqlite/Connection.php
SQLite compatibility implementation for the LEAST() SQL function.
Datelist::checkEmptyInputs in core/lib/Drupal/Core/Datetime/Element/Datelist.php
Checks the input array for empty values.
FieldInstanceOptionTranslation::transform in core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceOptionTranslation.php
Performs the associated process.
FieldOptionTranslation::transform in core/modules/field/src/Plugin/migrate/process/d6/FieldOptionTranslation.php
Get the field default/mapped settings.
FieldSettings::getSettings in core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php
Merge the default D8 and specified D6 settings.

... See full list

File

core/lib/Drupal/Component/Utility/FilterArray.php, line 27

Class

FilterArray
Provides methods to filter arrays.

Namespace

Drupal\Component\Utility

Code

public static function removeEmptyStrings(array $value) : array {
    return array_filter($value, static fn($item) => (string) $item !== '');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.