Jump to content

Sort with my value

- - - - -

  • Please log in to reply
1 reply to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hi guys,

How to sort array with name, and my name in top?

this is my array:

$arr = array("lemon", "orange", "banana", "apple", "soup");

if i use sort function, output is:
[0] = apple

[1] = banana

[2] = lemon

[3] = orange

[4] = soup

but i need soup in top.
for ex:
[0] = soup

[1] = apple

[2] = banana

[3] = lemon

[4] = orange

please help me, thank you

---------- Post added at 09:25 AM ---------- Previous post was at 09:13 AM ----------

and i need sort with value, no key

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
PHP: sort - Manual
Sort is probably what you are looking for.
If you want other type of sorting you have rsort, usort, uasort, uksort, ksort, arsort... and many other, they are all on this page




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users