@@ 1729-1749 (lines=21) @@ | ||
1726 | * @return string |
|
1727 | * @since 2.3.2009.03.13 |
|
1728 | */ |
|
1729 | public static function htmlSelectOptions($array, $default = 0, $withNull = true) |
|
1730 | { |
|
1731 | $ret = array(); |
|
1732 | $selected = ''; |
|
1733 | if ($withNull) { |
|
1734 | if ($default === 0) { |
|
1735 | $selected = " selected = 'selected'"; |
|
1736 | } |
|
1737 | $ret[] = '<option value=0' . $selected . '>---</option>'; |
|
1738 | } |
|
1739 | ||
1740 | foreach ($array as $index => $label) { |
|
1741 | $selected = ''; |
|
1742 | if ($index == $default) { |
|
1743 | $selected = " selected = 'selected'"; |
|
1744 | } |
|
1745 | $ret[] = "<option value=\"" . $index . "\"" . $selected . '>' . $label . '</option>'; |
|
1746 | } |
|
1747 | ||
1748 | return implode("\n", $ret); |
|
1749 | } |
|
1750 | ||
1751 | /** |
|
1752 | * Creates an html select |
@@ 1872-1892 (lines=21) @@ | ||
1869 | * @return string |
|
1870 | * @since 2.3.2009.03.13 |
|
1871 | */ |
|
1872 | public static function htmlSelectOptions($array, $default = 0, $withNull = true) |
|
1873 | { |
|
1874 | $ret = array(); |
|
1875 | $selected = ''; |
|
1876 | if ($withNull) { |
|
1877 | if ($default === 0) { |
|
1878 | $selected = " selected = 'selected'"; |
|
1879 | } |
|
1880 | $ret[] = '<option value=0' . $selected . '>---</option>'; |
|
1881 | } |
|
1882 | ||
1883 | foreach ($array as $index => $label) { |
|
1884 | $selected = ''; |
|
1885 | if ($index == $default) { |
|
1886 | $selected = " selected = 'selected'"; |
|
1887 | } |
|
1888 | $ret[] = "<option value=\"" . $index . "\"" . $selected . '>' . $label . '</option>'; |
|
1889 | } |
|
1890 | ||
1891 | return implode("\n", $ret); |
|
1892 | } |
|
1893 | ||
1894 | /** |
|
1895 | * Creates an html select |