Skip to content
Chung Leong edited this page Jan 10, 2022 · 4 revisions

array_search - Checks if a value exists in an array

int32 array_search ( mixed $needle, array $haystack )

array_search() searches haystack for needle and returns its position.

Parameters:

needle - The searched value. If haystack is a one-dimensional array, then needle should be a scalar. If haystack is a multi-dimensional array, then needle of should be an array of the same size as the subarrays of haystack. The size of needle must be known at compile-time. It cannot be an expandable array.

haystack - The array to perform the search on.

Return Value:

The array index at which needle was found or -1 if needle does not appear in haystack.

Notes:

Warning Unlike in regular PHP, array_search() returns -1 on failure in PHP+QB and not false.

Version

1.0 and above.

Clone this wiki locally