Skip to the content
Documentation

remove

No ratings yet

Summary

Returns the input array without some of the original elements.

Usage

input|remove( offset [, length ] )

Parameters

Name Type Description Required
offset integer The offset to start removing elements. Yes.
length integer The number of elements that should be removed. No.

Returns

A cut-down version of the input array.

Description

This operator removes element(s) from the input array and thus a chopped/cut-down version of the input array will be returned. The "offset" parameter must be used to define the start of the portion that should be removed. The "length" parameter can be used to define the number of elements that should be removed. If the "length" parameter is omitted, only one elemen (specified by offset will be removed).

Examples

Example 1
{array( 1, 2, 3, 4, 5 )|remove( 2, 2 )}

The following array will be returned: ( 1, 2, 5 ).

Example 2
{array( 1, 2, 3, 4, 5 )|remove( 2 )}

The following array will be returned: ( 1, 2, 4, 5 ).

Contributors

Comments (1 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. bug: if the length parameter is omitted, the rest of the array is removed

    VaL ·

    Fixed in
    3.6.11 (stable/3.6 rev. 16623),
    3.7.9 (stable/3.7 rev. 16622),
    3.8.4 (stable/3.8 rev. 16621),
    3.9.0alpha1 (trunk rev. 16620).

Comments

Add a comment

Comments are read by a moderator before they appear.