]> git.joonet.de Git - adminer.git/commitdiff
Avoid big ternary operator (saves memory)
authorJakub Vrana <jakub@vrana.cz>
Mon, 21 Mar 2011 08:53:41 +0000 (09:53 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 21 Mar 2011 09:06:27 +0000 (10:06 +0100)
adminer/include/functions.inc.php

index 5e0525d988551e7e22e371f915fec5adb970a05f..e32e8db7765e620c017bea3d9d0120b08222c0f8 100644 (file)
@@ -104,10 +104,12 @@ function checkbox($name, $value, $checked, $label = "", $onclick = "") {
 function optionlist($options, $selected = null, $use_keys = false) {
        $return = "";
        foreach ($options as $k => $v) {
+               $opts = array($k => $v);
                if (is_array($v)) {
                        $return .= '<optgroup label="' . h($k) . '">';
+                       $opts = $v;
                }
-               foreach ((is_array($v) ? $v : array($k => $v)) as $key => $val) {
+               foreach ($opts as $key => $val) {
                        $return .= '<option' . ($use_keys || is_string($key) ? ' value="' . h($key) . '"' : '') . (($use_keys || is_string($key) ? (string) $key : $val) === $selected ? ' selected' : '') . '>' . h($val);
                }
                if (is_array($v)) {