Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
arrays.index_to_int
arrays.index_to_int(array_of_inputs, index)
Description
Renvoie la valeur à un index donné dans un tableau sous forme d'entier.
L'index est une valeur entière qui représente la position d'un élément dans le tableau.
Par défaut, le premier élément d'un tableau a un index de 0 et le dernier élément a un index de n-1, où n est la taille du tableau.
L'indexation négative permet d'accéder aux éléments de tableau par rapport à la fin du tableau. Par exemple, un index de -1 fait référence au dernier élément du tableau et un index de -2 fait référence à l'avant-dernier élément du tableau.
Types de données des paramètres
ARRAY_STRINGS|ARRAY_INTS|ARRAY_FLOATS
, INT
Type renvoyé
INT
Exemples de code
Exemple 1
Cet appel de fonction renvoie 0 lorsque la valeur à l'index est une chaîne non numérique.
arrays.index_to_int(["str0", "str1", "str2"], 1) = 0
Exemple 2
Cette fonction renvoie l'élément à l'index -1.
arrays.index_to_int(["44", "11", "22", "33"], 0-1) = 33
Exemple 3
Renvoie 0 pour l'élément hors limites.
arrays.index_to_int(["44", "11", "22", "33"], 5) = 0
Exemple 4
Cette fonction récupère l'élément du tableau float à l'index 1.
arrays.index_to_int([1.100000, 1.200000, 1.300000], 1) = 1
Exemple 5
Cette fonction récupère l'élément du tableau d'entiers à l'index 0.
arrays.index_to_int([1, 2, 3], 0) = 1
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/29 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/29 (UTC)."],[[["\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"]]