Got a question that the wiki doesn't answer? Ask on the forum (preferred), or join us on IRC.

BeastNode

CommandHelper/Staged/API/array indexes

From EngineHub.org Wiki
Jump to: navigation, search



Vital Info

Name array_indexes
Returns array
Usages array, value
Throws CastException
Since 3.3.1
Restricted
No
Optimizations NO_SIDE_EFFECTS

Description

Returns an array with all the keys of the specified array at which the specified value is equal. That is, for the array(1, 2, 2, 3), if value were 2, would return array(1, 2). If the value cannot be found in the array at all, an empty array will be returned.

Usages

array_indexes(array, value)

Examples (How do these work?)

Example 1

Basic usage

Given the following code:

1   assign(@arrayarray(1, 2, 2, 3))
2   msg(array_indexes(@array, 2))


The output would be:

{1, 2}

Example 2

Not found

Given the following code:

1   assign(@arrayarray(1, 2, 2, 3))
2   msg(array_indexes(@array, 5))


The output would be:

{}





Navigation menu