I have a php for loop that generates a select list, but I can't figure out how to order the options of the list the way I want.
This is the php:
I was thinking of using either 'usort' or maybe even some javascript to sort the list of options in the select list. What I really need is to sort them in descending order.
This is the php:
Code:
static function tp_widget_do($args) {
echo '<span class="' . NO_TRANSLATE_CLASS . '">';
echo '<select name="lang" onchange="document.location.href=this.options[this.selectedIndex].value;">';
foreach ($args as $langrecord) {
$is_selected = $langrecord['active'] ? " selected=\"selected\"" : "";
echo "<option value=\"{$langrecord['url']}\"{$is_selected}>{$langrecord['langorig']}</option>";
}
echo "</select><br/>";
echo "</span>";
}
Comment