PHP Classes
elePHPant
Icontem

some fix in

Recommend this page to a friend!

      Forms  >  All threads  >  some fix in  >  (Un) Subscribe thread alerts  
Subject:some fix in
Summary:fix in selectBox method
Messages:1
Author:Svyatoslav Zhurovsky
Date:2010-12-16 03:41:55
 

  1. some fix in   Reply   Report abuse  
Svyatoslav Zhurovsky - 2010-12-16 03:41:55
Little fix:

function selectBox($array, $selected=0, $name='', $size=1, $multiple=false, $additional='') {
$res = '';
static $count = 0;
if (is_array($array)) {
if ($name == '') {
$name = 'selectBox' . ++$count;
}
$res .= "<select name=\"$name\" size=\"$size\"" . ($multiple==false ? '' : " multiple=\"multiple\"") . ($additional ? " $additional" : '') . ">\n";
$i = 0;
foreach($array as $key=>$value) {
$res .= "<option value={$value} " . ($selected == ++$i ? " selected=\"selected\"" : '') . ">$key</option>\n";
}
$res .="</select>\n";
}
return $res;
}