aboutsummaryrefslogtreecommitdiff
path: root/app/fn/fn.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/fn/fn.php')
-rw-r--r--app/fn/fn.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/app/fn/fn.php b/app/fn/fn.php
index 6dfeb2c..60e4722 100644
--- a/app/fn/fn.php
+++ b/app/fn/fn.php
@@ -2,6 +2,8 @@
use Wcms\Medialist;
+use function Clue\StreamFilter\fun;
+
function readablesize($bytes)
{
$format = ' %d %s';
@@ -292,7 +294,29 @@ function recurse_copy($src,$dst) {
}
}
closedir($dir);
-}
+}
+
+/**
+ * Generate a list of <options> html drop down list
+ *
+ * @param array $options as `value => title`
+ * @param string|int $selected value of actualy selected option
+ *
+ * @return string HTML list of options
+ */
+function options(array $options, $selected = null) : string
+{
+ $html = '';
+ foreach ($options as $value => $title) {
+ if($value == $selected) {
+ $attribute = 'selected';
+ } else {
+ $attribute = '';
+ }
+ $html .= '<option value="' . $value . '" ' . $attribute . '>' . $title . '</option>' . PHP_EOL;
+ }
+ return $html;
+}