Oihana PHP Arango

contains.php

Table of Contents

Functions

contains()  : string
Check whether a string contains a substring (case-sensitive).

Functions

contains()

Check whether a string contains a substring (case-sensitive).

contains(string $text, string $search[, bool $returnIndex = false ]) : string

This helper wraps the ArangoDB AQL function CONTAINS(text, search, returnIndex) which checks if the search string is contained within the text string. The matching is case-sensitive by default.

Example AQL usage:

CONTAINS("Hello World", "World")        // returns true
CONTAINS("Hello World", "world")        // returns false (case-sensitive)
CONTAINS("Hello World", "World", true)  // returns 6 (position)
Parameters
$text : string

The text to search in.

$search : string

The substring to search for.

$returnIndex : bool = false

When true, returns the position; when false, returns boolean.

Tags
throws
UnsupportedOperationException
example
use function oihana\arango\db\functions\strings\contains;

$expr = contains('doc.title', '"World"');
// Produces: 'CONTAINS(doc.title, "World")'

$expr = contains('doc.title', '"World"', true);
// Produces: 'CONTAINS(doc.title, "World", true)'
see
https://docs.arangodb.com/stable/aql/functions/string/#contains
since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results