By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,261 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,261 IT Pros & Developers. It's quick & easy.

problems sorting an array

P: n/a
hello ng!

got a problem sorting my multi-dimensional array. I have the following
situation of an array:

$fahrzeugarray[0]["fzid"]= "23"
$fahrzeugarray[0]["fzname"]="Audi TT"
$fahrzeugarray[1]["fzid"]= "34"
$fahrzeugarray[1]["fzname"]="VW Polo 1.2"
$fahrzeugarray[2]["fzid"]= "57"
$fahrzeugarray[2]["fzname"]="BMW Z3"

now i need to sort the array by 'fzname' before showing it. got to create
<SELECT> list with the 'fzid' as value and 'fzname' as text.
I use the following code to handle that but it doesn't work:

---------------------------------------------------------------------------------------
array_multisort($fahrzeugarray["fzname"]);
foreach($fahrzeugarray as $show_fza)
{
echo "<option
value='".$show_fza["fzid"]."'>".$show_fza["fzname"]."</option>";
}
---------------------------------------------------------------------------------------

when i start the script it shows the list without sorting it before. that's
a problem i try to solve sonce hours.
perhaps some one got an idea what is wrong with my script? :)

many thanks!

Jochen
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Jochen Califice <ma**@boomboxx.de> wrote:
now i need to sort the array by 'fzname' before showing it. got to create
<SELECT> list with the 'fzid' as value and 'fzname' as text.
I use the following code to handle that but it doesn't work:

array_multisort($fahrzeugarray["fzname"]);

when i start the script it shows the list without sorting it before. that's
a problem i try to solve sonce hours.
perhaps some one got an idea what is wrong with my script? :)


You read the manual page of array_multisort? It doesn't do what you
want, see http://php.net/usort example 2.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.