Skip to main content

Prepend to array

Anatomy

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

Description: ARRAY:UNSHIFT prepends a value to the beginning of an array.

Attention:

ARRAY:UNSHIFT is destructive, in the sense that it modifies the array in-place. It will re-index all numeric keys in the array.

Attributes

NameTypeDescriptionDefined By
varvarVariable name array:unshift

Results:

BindingTypePredicate
vararrayno-result-propagation

Examples

Example

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

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

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