findLast.php
Table of Contents
Functions
- findLast() : string
- Return the position of the last occurrence of a substring in a string.
Functions
findLast()
Return the position of the last occurrence of a substring in a string.
findLast(string $value, string $search, int|null $start, int|null $end) : string
This helper wraps the ArangoDB AQL function FIND_LAST(text, search, start, end)
which returns the position of the last 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_LAST("hello world", "o") // returns 7
FIND_LAST("hello world", "l") // returns 9
FIND_LAST("hello world", "x") // returns -1 (not found)
FIND_LAST("hello world", "o", 0, 5) // returns 4 (search in first 5 chars)
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.