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 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

(no description)

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

Defines 1 class

TextData:: (25 methods):
  CHARACTER()
  TRIMNONPRINTABLE()
  TRIMSPACES()
  ASCIICODE()
  CONCATENATE()
  DOLLAR()
  SEARCHSENSITIVE()
  SEARCHINSENSITIVE()
  FIXEDFORMAT()
  LEFT()
  MID()
  RIGHT()
  STRINGLENGTH()
  LOWERCASE()
  UPPERCASE()
  PROPERCASE()
  REPLACE()
  SUBSTITUTE()
  RETURNSTRING()
  TEXTFORMAT()
  VALUE()
  NUMBERVALUE()
  EXACT()
  TEXTJOIN()
  builtinREPT()


Class: TextData  - X-Ref


CHARACTER($character)   X-Ref
CHARACTER.

param: string $character Value
return: array|string

TRIMNONPRINTABLE($stringValue = '')   X-Ref
TRIMNONPRINTABLE.

param: mixed $stringValue Value to check
return: null|array|string

TRIMSPACES($stringValue = '')   X-Ref
TRIMSPACES.

param: mixed $stringValue Value to check
return: array|string

ASCIICODE($characters)   X-Ref
ASCIICODE.

param: array|string $characters Value
return: array|int|string A string if arguments are invalid

CONCATENATE(...$args)   X-Ref
CONCATENATE.

return: string

DOLLAR($value = 0, $decimals = 2)   X-Ref
DOLLAR.

This function converts a number to text using currency format, with the decimals rounded to the specified place.
The format used is $#,##0.00_);($#,##0.00)..

param: float $value The value to format
param: int $decimals The number of digits to display to the right of the decimal point.
return: array|string

SEARCHSENSITIVE($needle, $haystack, $offset = 1)   X-Ref
FIND.

param: array|string $needle The string to look for
param: array|string $haystack The string in which to look
param: array|int $offset Offset within $haystack
return: array|int|string

SEARCHINSENSITIVE($needle, $haystack, $offset = 1)   X-Ref
SEARCH.

param: array|string $needle The string to look for
param: array|string $haystack The string in which to look
param: array|int $offset Offset within $haystack
return: array|int|string

FIXEDFORMAT($value, $decimals = 2, $no_commas = false)   X-Ref
FIXEDFORMAT.

param: mixed $value Value to check
param: int $decimals
param: bool $no_commas
return: array|string

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

param: array|string $value Value
param: array|int $chars Number of characters
return: array|string

MID($value = '', $start = 1, $chars = null)   X-Ref
MID.

param: array|string $value Value
param: array|int $start Start character
param: array|int $chars Number of characters
return: array|string

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

param: array|string $value Value
param: array|int $chars Number of characters
return: array|string

STRINGLENGTH($value = '')   X-Ref
STRINGLENGTH.

param: string $value Value
return: array|int

LOWERCASE($mixedCaseString)   X-Ref
LOWERCASE.

Converts a string value to lower case.

param: array|string $mixedCaseString
return: array|string

UPPERCASE($mixedCaseString)   X-Ref
UPPERCASE.

Converts a string value to upper case.

param: string $mixedCaseString
return: array|string

PROPERCASE($mixedCaseString)   X-Ref
PROPERCASE.

Converts a string value to proper/title case.

param: array|string $mixedCaseString
return: array|string

REPLACE($oldText, $start, $chars, $newText)   X-Ref
REPLACE.

param: string $oldText String to modify
param: int $start Start character
param: int $chars Number of characters
param: string $newText String to replace in defined position
return: array|string

SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0)   X-Ref
SUBSTITUTE.

param: string $text Value
param: string $fromText From Value
param: string $toText To Value
param: int $instance Instance Number
return: array|string

RETURNSTRING($testValue = '')   X-Ref
RETURNSTRING.

param: mixed $testValue Value to check
return: null|array|string

TEXTFORMAT($value, $format)   X-Ref
TEXTFORMAT.

param: mixed $value Value to check
param: string $format Format mask to use
return: array|string

VALUE($value = '')   X-Ref
VALUE.

param: mixed $value Value to check
return: array|DateTimeInterface|float|int|string A string if arguments are invalid

NUMBERVALUE($value = '', $decimalSeparator = null, $groupSeparator = null)   X-Ref
NUMBERVALUE.

param: mixed $value Value to check
param: string $decimalSeparator decimal separator, defaults to locale defined value
param: string $groupSeparator group/thosands separator, defaults to locale defined value
return: array|float|string

EXACT($value1, $value2)   X-Ref
Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise.
EXACT is case-sensitive but ignores formatting differences.
Use EXACT to test text being entered into a document.

param: mixed $value1
param: mixed $value2
return: array|bool

TEXTJOIN($delimiter, $ignoreEmpty, ...$args)   X-Ref
TEXTJOIN.

param: mixed $delimiter
param: mixed $ignoreEmpty
param: mixed $args
return: array|string

builtinREPT($str, $number)   X-Ref
REPT.

Returns the result of builtin function repeat after validating args.

param: array|string $str Should be numeric
param: mixed $number Should be int
return: array|string