Skip to main content

member_array

Discworld driver help

member_array

Name

member_array() - returns index of an occurence of a given item in an
array or string

Synopsis

int member_array( mixed item, mixed arr );
int member_array( mixed item, mixed arr, int start );
int member_array( mixed item, mixed arr, int start, int flag );

Description

Returns the index of the first occurence of `item' in array or string `arr', or the first occurence at or after optional `start'. If the item is not found, then -1 is returned. The optional `flag' is a bitmap, where, if the 1 bit is set, `item' is a string and `arr' is an array of strings, only strlen(`item') chars are matched. If the 2 bit is set, member_array() will return the index of the last occurance instead of the first. In this case, `start' is counted from the last element of `arr'.

Examples

member_array( "frog", ({ "wombles", "frogbane", "frog" }) );
returns 2
member_array( "frog", ({ "wombles", "frogbane", "frog" }), 0, 1 );
returns 1
member_array( "frog", ({ "frog", "wombles", "frogbane", "frog" }), 0, 2 );
returns 3
member_array( "frog", ({ "frog", "wombles", "frogbane" }), 0, 3 );
returns 2

Notes

For the purpose of this efun, strings are considered to be arrays of ints.