2013-08-02, 03:14:52
for my new code I check whether the array is associative or not and build the dropdown using it.
Otherwise the dropdown uses the labels only
Then build the dropdown with
sorry its copy/pasted from new code, but you get the idea...
Otherwise the dropdown uses the labels only
Code:
* @param array $arr Array to check
* @return boolean True is array is associative
*/
public static function isAssoc($arr){
return array_keys($arr) !== range(0, count($arr) - 1);
}
Then build the dropdown with
Code:
if (!Arr::isAssoc($options)){
foreach($options as $item){
$this->value .= ' <option value="'.($item).'"';
if (($value)==($item)) $this->value .= " selected ";
$this->value .='>'.$item.'</option>';
}
} else {
foreach($options as $item=>$value2){
$this->value .= ' <option value="'.($item).'"';
if (($value)==($item)) $this->value .= " selected ";
$this->value .='>'.$value2.'</option>';
}
}
sorry its copy/pasted from new code, but you get the idea...