aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2021-05-18 16:54:10 -0400
committerGravatar GitHub <noreply@github.com> 2021-05-18 22:54:10 +0200
commit235ff3863ddb359a7f0e9ec9402f8f49fecef074 (patch)
treed714d9d5b2161fd456dde56c3a922fbd2de923e3 /lib
parent8d8b792007acd7c49e49ecc4e512ff594436656d (diff)
Add a request method to extract arrays (#3629)
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Request.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index 614473dd4..232479191 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -58,6 +58,19 @@ class Minz_Request {
}
return $value;
}
+ /**
+ * Extract text lines to array.
+ *
+ * It will return an array where each cell contains one line of a text. The new line
+ * character is used to break the text into lines. This method is well suited to use
+ * to split textarea content.
+ */
+ public static function paramTextToArray($key, $default = []) {
+ if (isset(self::$params[$key])) {
+ return preg_split('/\R/', self::$params[$key]);
+ }
+ return $default;
+ }
public static function defaultControllerName() {
return self::$default_controller_name;
}