Skip to main content

Reverse array

Anatomy

<array:reverse var="var" var_result="(destructive on 'var')"/>

Description: ARRAY:REVERSE reverses the item order of an array.

Attention:

ARRAY:REVERSE is destructive, in the sense that it modifies the array in-place, unless 'var_result' is specified in which case a copy of the resulting array will be stored in 'var_result' instead. It preserves the key and value associations of the array.

Attributes

NameTypeDescriptionDefined By
varvarVariable name array:reverse
var_resultvarResult variable name array:reverse

Results:

BindingTypePredicate
varvar_resultarray

Examples

Example

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

<array:reverse var="names"/>

<foreach var="names" var_value="name">
<output>$name&n;</output>
</foreach>

<!--
Steve Jobs
Bill Gates
-->