0

i have this array on php:

Array ( [googlewindow] => 1 [google] => 6 [kei] => 1 [uutntpzlfcewtgfer] => 2 [dbq] => 2 [kexpi] => 1 [kcsi] => 1 [e] => 8 [ei] => 1 [expi] => 1 [ml] => 1 [function] => 5 [khl] => 1 [es] => 1 [time] => 2 [return] => 1 [new] => 3 [date] => 2 [gettime] => 2 [log] => 1 [b] => 2 [d] => 2 [c] => 6 [var] => 5 [a] => 12 [image] => 1 [g] => 3 [lc] => 2 [f] => 4 [li] => 3 [onerror] => 1 [onload] => 1 [onabort] => 1 [delete] => 1 [gen] => 1 [atyp] => 1 [i] => 1 [ct] => 1 [cad] => 1 [zx] => 1 [src] => 1 [toolbelt] => 1 [window] => 3 [sn] => 1 [webhp] => 1 [timers] => 1 [load] => 1 [t] => 1 [start] => 1 [try] => 1 [catch] => 1 [u] => 1 [jsrt] => 1 [kill] => 1 [gjwl] => 3 [location] => 1 [gjuc] => 1 [href] => 2 [indexof] => 4 [if] => 3 [substring] => 2 [q] => 2 [-] => 1 [for] => 1 )

How can i using a FOR or WHILE instruction sort from MAX to MIN and then print the result? Thanks!

1 Answer 1

3

Take look at asort():

This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant.

PHP has many built in array sorting functions.

Sign up to request clarification or add additional context in comments.

1 Comment

The point of PHP, with its mass of built-in functions, is to use them instead of coding it yourself, which will almost always be slower/less efficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.