Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to arrange associative array elements? a function?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to arrange associative array elements? a function?

Postby Tony121076 » Tue Mar 04, 2003 10:46 am

I have an associative array where the $keys = a name, and the $values = a number. I need to arrange the elements based on the $value (which is a number), from greatest to least. Is there a function for this? If not, what is the best way to handle this? (NOTE: some elements have the same number value) Thanks in advance.
Tony121076
New php-forum User
New php-forum User
 
Posts: 28
Joined: Fri Jan 03, 2003 4:00 pm

Postby Redcircle » Tue Mar 04, 2003 11:33 am

arsort($value)

http://www.php.net/arsort

remember to check the manual. it is your friend.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.