array sorting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there,

I would like to save some db power by putting values into a file which are often used. They basicly populate a select field.
So I placed those values into associative arrays:
$code[language] = array("1"=> "php", "2"=> "asp");


Now I would like to sort those for displaying after my preference, not by lets say alphabet. The easiest thing I could think of, is just to move the entry:
$code[language] = array("2"=> "asp", "1"=> "php");


But this of course does not work. I would like to be able to place values later on inbetween. So if somebody comes up with a language called ".net" :-) I would like to place it in the middle, but I cant get it to work like that :-(

To build the select box I use following code:

<select name="education">
<option value ="0" selected>---</option>
';
################################################
# build the select field
for ($i=1; $i <= count($code[education]); $i++){
if ($education)
$isselected = ($i == $education) ? " selected" : ""; // select the active row
else
$isselected = FALSE;
printf ("<option value =\"%s\"%s>%s</option>\n", $i, $isselected, $code[education][$i]);
};
################################################
echo'
</select>


Has anybody an idea which could help me on that? Thank you for any help.

Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux