johnhamelink
6/27/2012 - 10:30 AM

research.php

    /**
     * makeOption
     *
     * Converts a multidimentional array
     * into a string of <option> tags, and
     * marks the default as "selected".
     *
     * @param Array $array
     *
     * @return String $result
     *
     */
    private function makeOption(Array $array) {
        $result = "";
        foreach ($array as $id => $value) {
            $selected = "";
            // If this value is the default,
            // lets mark it as selected.
            if (is_array($value)) {
                $value = $value[1];
                $selected = 'selected="selected"';
            }

            $result .= "<option value='{$id}' {$selected}>{$value}</option>";
            var_dump($result);
        }
        return $result;
    }