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

BeastNode

CommandHelper/Staged/API/array index

From EngineHub.org Wiki
Jump to: navigation, search



Vital Info

Name array_index
Returns mixed
Usages array, value
Throws CastException
Since 3.3.1
Restricted
No
Optimizations None

Description

Works exactly like array_indexes(array, value)[0], except in the case where the value is not found, returns null. That is to say, if the value is contained in an array (even multiple times) the index of the first element is returned.

Usages

array_index(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_index(@array, 2))


The output would be:

1

Example 2

Not found

Given the following code:

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


The output would be:

null





Navigation menu