findFirst.php
Table of Contents
Functions
- findFirst() : string
- Return the position of the first occurrence of a substring in a string.
Functions
findFirst()
Return the position of the first occurrence of a substring in a string.
findFirst(string $value, string $search, int|null $start, int|null $end) : string
This helper wraps the ArangoDB AQL function FIND_FIRST(text, search, start, end)
which returns the position of the first occurrence of the search string within
the text string. Positions start at 0. You can optionally limit the search
to a subset of the text using start and end parameters.
Example AQL usage:
FIND_FIRST("hello world", "world") // returns 6
FIND_FIRST("hello world", "o") // returns 4
FIND_FIRST("hello world", "x") // returns -1 (not found)
FIND_FIRST("hello world", "o", 5) // returns 7 (search from position 5)
Parameters
- $value : string
-
The text to search in (haystack).
- $search : string
-
The substring to search for (needle).
- $start : int|null
-
Optional start position to limit search (default: 0).
- $end : int|null
-
Optional end position to limit search (default: end of string).
Tags
Return values
string —The formatted AQL expression.