Search a String, Number, or Array for a value.
Syntax
Parameters
subject
- The entity to search.search
- The values to search for.subject
is searched for any occurrences of the String.subject
is a String, the Number will be treated as a String. Otherwise, matching depends on the strict
parameter.subject
is an Array, in which case, any occurrences will be searched for; that is, only sub-Arrays that match search
will be found.subject
is an Array, in which case, any occurrences will be searched for.all
- Whether to search for all matches, or just the first.false
(default) - Just the first match will be found, and its position returned.true
- All matches will be found, in which case their positions will be returned as an Array.strict
- Whether to employ strict matching.false
(default) - If subject
is a String, the match will be case-insensitive. Otherwise, if subject
is an Array, item types will not be checked, only item values.true
- If subject
is a String, the match will be case-sensitive. Otherwise, if subject
is an Array, item types will have to match as well as values. Array searches are always case-sensitive.false
(default) - subject
will be searched from start to end.true
- subject
will be searched from end to start. The first match will therefore be the last match, and if all
is true
then the Array of matches will be in reverse order.start
- The optional start
parameter only has any effect if subject
is a String (or a Number), and is the position to start searching from. If start
is non-negative, the position will be calculated from the beginning of subject
, otherwise it will be calculated from the end. If reverse
is true, this calculation will be reversed, although the positions returned will always be counted from the actual start of subject
.
Result
all
is false
, and subject
is a String, or the first match is a numeric key if subject
is an Array.all
is true
, all the matches will be returned as an Array. If subject
is a String, all the match positions will be numeric, otherwise if subject
is an Array, some match positions can be Strings, as the keys of the matches will be returned.false
will be returned.
Returns the positions of either the first match or all matches of search
in subject
.