Navigation Menu

Skip to content

Commit

Permalink
Avoid big ternary operator (saves memory)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Mar 21, 2011
1 parent 08650ee commit 2f76084
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion adminer/include/functions.inc.php
Expand Up @@ -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)) {
Expand Down

0 comments on commit 2f76084

Please sign in to comment.