PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I sort the members of an array by value?


If you wish to sort the members of an array by value - which is probably one of the most common requirements with arrays as we tend to like to order things, use the sort function.

This takes the array as its parameter, as in sort($array).

Here's a simple example:

<?php
$myworld 
= array("world","hello");
sort($myworld);
print_r($myworld);
?>


Which looks a little like this:

Array
(
[0] => hello
[1] => world
)



ASK A QUESTION

More arrays PHP Questions

How can I sort a multi-dimensional array?

How do I sort alphanumeric array data correctly?

How do I remove and view the last element of an array?

I'm shuffeling through numbers range(1, 10). Can I eval resulting random numbers and convert to appropriate text? 1 = username1, 2 = username2...etc?

How do I return all the values in an array?



Custom Search