From 42441e78c27a608af0976854bdae228ffa5d5ea4 Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Thu, 4 Jun 2020 09:27:09 +0700 Subject: [PATCH] add string replace --- src/Lib/Strings.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Lib/Strings.php b/src/Lib/Strings.php index 483cb40..2537050 100644 --- a/src/Lib/Strings.php +++ b/src/Lib/Strings.php @@ -17,7 +17,7 @@ class Strings implements ILib fn (string $a) => strtoupper($a) )); - $env->set('locase', new CoreFunc('locase', 'Return string in lower case.', 1, 1, + $env->set('lowcase', new CoreFunc('lowcase', 'Return string in lower case.', 1, 1, fn (string $a) => strtolower($a) )); @@ -31,6 +31,10 @@ class Strings implements ILib } )); + $env->set('replace', new CoreFunc('replace', 'Change occurrences in first argument from second argument to third argument.', 3, 3, + fn (string $a, string $b, string $c) => str_replace($b, $c, $a) + )); + $env->set('split', new CoreFunc('split', 'Split the second argument by the first argument into a list.', 2, 2, fn (string $a, string $b) => new MList(explode($a, $b)) ));