aboutsummaryrefslogtreecommitdiffstats
path: root/core/functions.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-21 18:58:59 +0200
committerThomas Lange <code@nerdmind.de>2021-06-21 18:58:59 +0200
commit95ce6b8cea9bb79f82e43f99639fa3371a809cbb (patch)
tree74fdec761f7326b0f6e1cf30858fd47391b519b1 /core/functions.php
parent57019638f3b72c42d9b72cab6f060537edbee038 (diff)
downloadblog-95ce6b8cea9bb79f82e43f99639fa3371a809cbb.tar.gz
blog-95ce6b8cea9bb79f82e43f99639fa3371a809cbb.tar.xz
blog-95ce6b8cea9bb79f82e43f99639fa3371a809cbb.zip
Add function parseArguments
Diffstat (limited to 'core/functions.php')
-rw-r--r--core/functions.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/functions.php b/core/functions.php
index 4b3eabd..5fd1b39 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -200,6 +200,26 @@ function getMarkdownImageURLs(string $text): array {
}
#===============================================================================
+# Parse argument string to array
+#===============================================================================
+function parseArguments(?string $argv): array {
+ if($argv) {
+ foreach(explode('|', $argv) as $delimeter) {
+ $part = explode('=', $delimeter);
+
+ $argumentK = $part[0] ?? NULL;
+ $argumentV = $part[1] ?? TRUE;
+
+ if(preg_match('#^[[:word:]]+$#', $argumentK)) {
+ $arguments[strtoupper($argumentK)] = $argumentV;
+ }
+ }
+ }
+
+ return $arguments ?? [];
+}
+
+#===============================================================================
# Parser for datetime formatted strings [YYYY-MM-DD HH:II:SS]
#===============================================================================
function parseDatetime($datetime, $format): string {