Zum Hauptinhalt springen

Push onto array

Anatomy

<array:push var="var">
string
</array:push>

Description: ARRAY:PUSH pushes a value onto the end of an array.

ARRAY:PUSH will implicitly generate a consecutive numeric key.

These three statements are semantically equivalent:

value value

Attention:

ARRAY:PUSH is destructive, in the sense that it modifies the array in-place. It preserves the key and value associations of the array.

Attributes

NameTypeDescriptionDefined By
varvarVariable name array:push

Results:

BindingTypePredicate
vararrayno-result-propagation

Examples

Example

<array var="names">
<item>Bill Gates</item>
</array>

<array:push var="names">Steve Jobs</array:push>
<output>$names[0] and $names[1] are competitors!</output>

<!-- Bill Gates and Steve Jobs are competitors! -->