This is the documentation for the development version. There are no official binaries for it; build it from the source code in git. Download links on these pages work only after the release. For the current release, see version 7.0.

substr()

Deprecated in 5.0.

Replaced with method substring() of the string instance.

substr(string, n, len): String

Extracts the substring from string that begins at the nth character and is of length len.

Table 1. Parameters

string

String

Source string.

n

Integer

Starting character index for substring. The n must be a positive whole number. If n is greater than length(string), then empty string is returned.

len

Integer

Length of substring. If you omit length, the rest of the string is returned. Optional parameter.

Return

Extracted substring.

print(substr("abcdef", 3, 2)); //Will print: "cd"
print(substr("abcdef", 8)); //Will print: ""
print(substr("abcdef", 4)); //Will print: "def"