Permalink
Browse files

Avoid big ternary operator (saves memory)

  • Loading branch information...
1 parent 08650ee commit 2f76084bbd8a6fb594543d0a7ea7ba7a13a89311 @vrana committed Mar 21, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 adminer/include/functions.inc.php
View
4 adminer/include/functions.inc.php
@@ -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)) {

0 comments on commit 2f76084

Please sign in to comment.