Extracted from Pike v7.3 release 53 at 2002-09-10.
pike.ida.liu.se
[Top]

Method search()


Method search

int search(string haystack, string|int needle, int|void start)
int search(array haystack, mixed needle, int|void start)
mixed search(mapping haystack, mixed needle, mixed|void start)

Description

Search for needle in haystack. Return the position of needle in haystack or -1 if not found.

If the optional argument start is present search is started at this position.

When haystack is a string needle must be a string or an int, and the first occurrence of the string or int is returned.

When haystack is an array, needle is compared only to one value at a time in haystack.

When haystack is a mapping, search tries to find the index connected to the data needle. That is, it tries to lookup the mapping backwards. If needle isn't present in the mapping, zero is returned, and zero_type() will return 1 for this zero.

See also

indices, values, zero_type