Skip to main content

Pad array

Anatomy

<array:pad var="var" var_result="(destructive on 'var')" length="int" padding="(NULL)"/>

Description: ARRAY:PAD pads an array to a given length.

If the length is positive then the array is padded on the right, if it is negative then on the left. If the absolute length is less than or equal to the actual length of the array then no padding takes place.

Attention:

ARRAY:PAD 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 will re-index all keys in the array numerically.

Attributes

NameTypeDescriptionDefined By
varvarVariable name array:pad
var_resultvarResult variable name array:pad
lengthintLength array:pad
paddingstringPadding value array:pad

Results:

BindingTypePredicate
varvar_resultarray

Examples

Example

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

<array:pad var="names" length="3" padding="Larry Ellison"/>
<output>$names[1] and $names[2] are friends!</output>

<!-- Steve Jobs and Larry Ellison are friends! -->