Skip to content

Commit

Permalink
Document updated withoutKey behavior.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Stein committed Jan 26, 2021
1 parent e037c6f commit 54fa7ed
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docs/3.x/dev/filters.md
Expand Up @@ -1052,7 +1052,9 @@ Returns an array without the specified element(s).

## `withoutKey`

Returns an array without the specified key.
Returns an array without one or more specified keys.

The key can be a single key as a string:

```twig
{% set array = {
Expand All @@ -1061,4 +1063,17 @@ Returns an array without the specified key.
baz: 'baz'
} %}
{% set filtered = array|withoutKey('baz') %}
{# Result: { 'foo': 'foo', 'bar: 'bar' } #}
```

You can also pass multiple keys in an array:

```twig
{% set array = {
foo: 'foo',
bar: 'bar',
baz: 'baz'
} %}
{% set filtered = array|withoutKey(['bar', 'baz']) %}
{# Result: { 'foo': 'foo' } #}
```

0 comments on commit 54fa7ed

Please sign in to comment.