ltrim().
Allows you to create a function which can be used to trim any matches from a mask. Trims the matching values from the start only These can either be used as part of a Higher Order Function such as array_map() or as part of a compiled/pipe function.
/**
* @param string $mask
* @return Closure(string):string
*/
Strings\lTrim(string $mask = "\t\n\r\0\x0B"): ClosureWhen Strings\lTrim() is called, it returns the following Closure which can be used like a regular function.
/**
* @param string $string The string to be trimmed
* @return string
* @psalm-pure
*/
$function(string $string): stringRelated Functions
This can be used to create a simple closure which can be used as a regular function.
// Create a closure which will get all instances of IT in a string.
$trimStar = Strings\lTrim('*');
// Called as a function.
echo $trimStar('*This is a string, with it in it*'); // This is a string, with it in it*
// Used in a higher order function.
$array = array_map( $trimStar, ['**Hi*****', '***Bye*']);
print_r($array); // ['Hi*****', 'Bye*']This can be called inline using currying.
echo Strings\lTrim('_')('___This is a string, with it in it___'); // This is a string, with it in it___If you are not planning on reusing the Closure created, you can just call it inline with a higher order function as its callable.
$array = array_map(Strings\lTrim('-'), ['--Hi-', '-Bye--']);
print_r($array); // ['Hi-', 'Bye---']