Get last $n elements of a given array

array:get_tail(ARRAY $array, INT $n=1) : ARRAY

# the following gets the last element with its associated key
array:get_tail([1,2,3,4])
#=> [ 3 => 4 ]

# get the last 2 elements with their associated keys
array:get_tail([1,2,3,4], 2)
#=> [ 2 => 3, 3 => 4 ]

Copyright ©2013-2022 SunSed®. All rights reserved.