how to sort value in associative array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
destiny_cores
Forum Newbie
Posts: 8
Joined: Fri Mar 17, 2006 9:05 am

how to sort value in associative array

Post by destiny_cores »

I have an array

Array (
  • => 2 [comput ] => 3 [vision ] => 4 [confer ] => 3 [homepag ] => 1 [includ ] => 1 [major ] => 1 [link ] => 1 [websit ] => 1 [comprehens ] => 1 [workshop ] => 1 [import ] => 1 [date ] => 1 [submiss ] => 1 [deadlin ] => 1 [maintain ] => 1 [keith ] => 1 [price ] => 1 )

    if I want to sort value from max to min such as

    [vision]=4
    [comput]=3
    [confer]=3
    • =2
      .
      .
      .
      [price]=1

      How should I do ?

      Thanks.
Last edited by destiny_cores on Sat Jul 29, 2006 3:24 pm, edited 1 time in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

asort();
ksort();
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please be aware we have policies covering vague and ambiguous thread titles. This is a friendly reminder only.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
destiny_cores
Forum Newbie
Posts: 8
Joined: Fri Mar 17, 2006 9:05 am

Post by destiny_cores »

I 'm sorry Feyd
Post Reply