Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 280 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Extract:: (8 methods):
  left()
  mid()
  right()
  before()
  after()
  validateTextBeforeAfter()
  buildDelimiter()
  matchFlags()


Class: Extract  - X-Ref

left($value, $chars = 1)   X-Ref
LEFT.

param: mixed $value String value from which to extract characters
param: mixed $chars The number of characters to extract (as an integer)
return: array|string The joined string

mid($value, $start, $chars)   X-Ref
MID.

param: mixed $value String value from which to extract characters
param: mixed $start Integer offset of the first character that we want to extract
param: mixed $chars The number of characters to extract (as an integer)
return: array|string The joined string

right($value, $chars = 1)   X-Ref
RIGHT.

param: mixed $value String value from which to extract characters
param: mixed $chars The number of characters to extract (as an integer)
return: array|string The joined string

before($text, $delimiter, $instance = 1, $matchMode = 0, $matchEnd = 0, $ifNotFound = ')   X-Ref
TEXTBEFORE.

param: mixed $text the text that you're searching
param: null|array|string $delimiter the text that marks the point before which you want to extract
param: mixed $instance The instance of the delimiter after which you want to extract the text.
param: mixed $matchMode Determines whether the match is case-sensitive or not.
param: mixed $matchEnd Treats the end of text as a delimiter.
param: mixed $ifNotFound value to return if no match is found
return: mixed|mixed[] the string extracted from text before the delimiter; or the $ifNotFound value

after($text, $delimiter, $instance = 1, $matchMode = 0, $matchEnd = 0, $ifNotFound = ')   X-Ref
TEXTAFTER.

param: mixed $text the text that you're searching
param: null|array|string $delimiter the text that marks the point before which you want to extract
param: mixed $instance The instance of the delimiter after which you want to extract the text.
param: mixed $matchMode Determines whether the match is case-sensitive or not.
param: mixed $matchEnd Treats the end of text as a delimiter.
param: mixed $ifNotFound value to return if no match is found
return: mixed|mixed[] the string extracted from text before the delimiter; or the $ifNotFound value

validateTextBeforeAfter(string $text, $delimiter, int $instance, $matchMode, $matchEnd, $ifNotFound)   X-Ref

param: null|array|string $delimiter
param: int $matchMode
param: int $matchEnd
param: mixed $ifNotFound
return: string|string[]

buildDelimiter($delimiter)   X-Ref

param: null|array|string $delimiter the text that marks the point before which you want to extract

matchFlags(int $matchMode)   X-Ref
No description