trim_start

Remove leading characters from string

Definition

string trim_start(string $string, array[string] $charactersToRemove)

Removes $charactersToRemove from end of $string.

Parameters

string $string

The string to remove characters from.

array[string] $charactersToRemove

An array containing the characters to remove from the string.

If left empty, all whitespace characters are removed.

Returns

string

$string with the characters removed.

Examples

{
  a: trim_start('abcMyStringabc', ['a']),
  b: trim_start('abcMyStringabc', ['a','b']),
  c: trim_start('abcMyStringabc', ['a','b','c']),
  d: trim_start('_I have a string_', ['_']),
  e: trim_start('I have a string_', ['_']),
  f: trim_start('No need to trim', []),
  g: trim_start(null, [])
}
{
  "a": "bcMyStringabc",
  "b": "cMyStringabc",
  "c": "MyStringabc",
  "d": "I have a string_",
  "e": "I have a string_",
  "f": "No need to trim",
  "g": null
}