startsWith.php
Table of Contents
Functions
- startsWith() : string
- Check whether a string starts with a prefix (or with one of several prefixes).
Functions
startsWith()
Check whether a string starts with a prefix (or with one of several prefixes).
startsWith(string $value, string|array<string|int, mixed> $prefix[, int|null $minMatchCount = null ]) : string
This helper wraps the ArangoDB AQL function STARTS_WITH(text, prefix) which
checks if the given string starts with the specified prefix. The comparison
is case-sensitive.
Inside a SEARCH operation the ArangoSearch form
STARTS_WITH(path, prefixes, minMatchCount) is also supported: pass an
array of prefixes (emitted with json_encode, so plain strings are
quoted) and an optional minimum number of prefixes that must match.
A string prefix is kept raw, as before (callers quote it themselves).
Example AQL usage:
STARTS_WITH("hello world", "hello") // returns true
STARTS_WITH("hello world", "world") // returns false
STARTS_WITH("Hello world", "hello") // returns false (case-sensitive)
STARTS_WITH(doc.text, ["lor", "ips"], 1) // SEARCH form: at least 1 prefix matches
Parameters
- $value : string
-
String expression to check.
- $prefix : string|array<string|int, mixed>
-
Prefix to test for: a raw string expression (kept as-is), or an array of prefix strings (JSON-encoded).
- $minMatchCount : int|null = null
-
Optional minimum number of prefixes that must match (ArangoSearch
SEARCHform, used with an array of prefixes).
Tags
Return values
string —The formatted AQL expression.