/
popElement

popElement



Function: popElement

Removes and returns the last element of a list. Returns null if performed on an empty list.

Syntax

popElement(array)

ArgumentTypeDescription
arrayArrayList of values

Examples

$aList = [ 1, 2 ],

popElement($aList)

The new value of $alist is [ 1 ] (a list containing a single member, the integer 1)


$aList = [ 1, 2 ],

$lastElement = popElement($aList)

$lastElement now has the integer value 2 (not in a list) and, as before, the new value of $alist is [ 1 ] 


popElement([2,0,1])

popElement() returns the value 1 and removes this element from the list, leaving [2,0]. Since the list [ 2,0,1 ] was never assigned to a variable, this operation simply returns the value 1 and has no other effects.


$discountFilter = ifNull($discountFilterId, _NULL, popElement($discountFilters)

popElement() returns the discount filter from the end of the list of filters, then removes this filter from the list.

See Also

Related content

addElement
addElement
More like this
excluded
excluded
Read with this
popElement
popElement
More like this
SubList Macro
SubList Macro
Read with this
popElement
popElement
More like this
split
split
Read with this