使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
arrays.index_to_int
arrays.index_to_int(array_of_inputs, index)
说明
以整数形式返回数组中指定索引处的值。
索引是一个整数值,表示数组中元素的位置。
默认情况下,数组的第一个元素的索引为 0,最后一个元素的索引为 n-1,其中 n 是数组的大小。
负索引可用于访问数组中相对于数组末尾的元素。例如,索引 -1 表示数组中的最后一个元素,索引 -2 表示数组中的倒数第二个元素。
形参数据类型
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
,INT
返回类型
INT
代码示例
示例 1
当索引处的值为非数字字符串时,此函数调用会返回 0。
arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
示例 2
此函数返回索引为 -1 的元素。
arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
示例 3
对于越界元素,返回 0。
arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
示例 4
此函数从索引为 1 的浮点数组中提取元素。
arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
示例 5
此函数从索引 0 处的 int 数组中提取元素。
arrays.index_to_int([1, 2, 3], 0) = 1
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-29。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-29。"],[[["\u003cp\u003e\u003ccode\u003earrays.index_to_int\u003c/code\u003e retrieves an element from an array at a specified index and returns it as an integer.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports positive and negative indexing, with negative indices counting from the end of the array.\u003c/p\u003e\n"],["\u003cp\u003eIf the element at the specified index is a non-numeric string or the index is out of bounds, the function returns 0.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes two parameters, the first being the array (that can consist of string, integers or float values), and the second the index (an integer).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003earrays.index_to_int\u003c/code\u003e is supported in both Rules and Search.\u003c/p\u003e\n"]]],[],null,["### arrays.index_to_int\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n arrays.index_to_int(array_of_inputs, index)\n\n#### Description\n\nReturns the value at a given index in an array as an integer.\n\nThe index is an integer value which represents the position of an element in the array.\nBy default, the first element of an array has an index of 0, and the last element has an index of n-1, where n is the size of the array.\nNegative indexing allows accessing array elements relative to the end of the array. For example, an index of -1 refers to the last element in the array and an index of -2 refers to the second to last element in the array.\n\n#### Param data types\n\n`ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS`, `INT`\n\n#### Return type\n\n`INT`\n\n#### Code samples\n\n##### Example 1\n\nThis function call returns 0 when the value at the index is a non-numeric string. \n\n arrays.index_to_int([\"str0\", \"str1\", \"str2\"], 1) = 0\n\n##### Example 2\n\nThis function returns the element at index -1. \n\n arrays.index_to_int([\"44\", \"11\", \"22\", \"33\"], 0-1) = 33\n\n##### Example 3\n\nReturns 0 for the out-of-bounds element. \n\n arrays.index_to_int([\"44\", \"11\", \"22\", \"33\"], 5) = 0\n\n##### Example 4\n\nThis function fetches the element from the float array at index 1. \n\n arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1\n\n##### Example 5\n\nThis function fetches the element from the int array at index 0. \n\n arrays.index_to_int([1, 2, 3], 0) = 1"]]