Oihana PHP Arango

subString.php

Table of Contents

Functions

subString()  : string
Return a substring of a string.

Functions

subString()

Return a substring of a string.

subString(string $value, int $offset[, int|null $length = null ]) : string

This helper wraps the ArangoDB AQL function SUBSTRING(value, offset, length) which extracts a substring from the given string starting at the specified offset with the optional length. Negative offsets start from the end of the string.

Example AQL usage:

SUBSTRING("hello world", 0, 5)    // returns "hello"
SUBSTRING("hello world", 6)       // returns "world"
SUBSTRING("hello world", -5)      // returns "world" (from end)
SUBSTRING("hello world", 0, 3)    // returns "hel"
Parameters
$value : string

String expression to extract substring from.

$offset : int

Starting position (0-based, negative values start from end).

$length : int|null = null

Optional length of substring (default: to end of string).

Tags
example
use function oihana\arango\db\functions\strings\subString;

$expr = subString('doc.text', 0, 10);
// Produces: 'SUBSTRING(doc.text, 0, 10)'
see
https://docs.arangodb.com/3.12/aql/functions/string/#substring
left()

For extracting from the beginning.

right()

For extracting from the end.

since
1.0.0
author

Marc Alcaraz

Return values
string

The formatted AQL expression.

On this page

Search results