array_slice()array_slice()

提取动态数组的切片。Extracts a slice of a dynamic array.

语法Syntax

array_slice( arr , start , end )array_slice( arr , start , end )

参数Arguments

  • arr :要从中提取切片的输入数组必须是动态数组。arr : Input array to extract the slice from must be dynamic array.
  • start:切片的从零开始(包括零)的开始索引,负值转换为 array_length+start。start : zero-based (inclusive) start index of the slice, negative values are converted to array_length+start.
  • end:切片的从零开始(包括零)的结束索引,负值转换为 array_length+end。end : zero-based (inclusive) end index of the slice, negative values are converted to array_length+end.

注意:忽略超出范围的索引。Note: out of bounds indices are ignored.

返回Returns

arr 中处于 [start..end] 范围内的值的动态数组。Dynamic array of the values in the range [start..end] from arr.

示例Examples

print arr=dynamic([1,2,3]) 
| extend sliced=array_slice(arr, 1, 2)
arr sliced
[1,2,3][1,2,3] [2,3][2,3]
print arr=dynamic([1,2,3,4,5]) 
| extend sliced=array_slice(arr, 2, -1)
arr 已切片sliced
[1,2,3,4,5][1,2,3,4,5] [3,4,5][3,4,5]
print arr=dynamic([1,2,3,4,5]) 
| extend sliced=array_slice(arr, -3, -2)
arr 已切片sliced
[1,2,3,4,5][1,2,3,4,5] [3,4][3,4]