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 do I add to the end of an array and know how large the array is?

what are php array functions?

How do I reverse sort an array by key?

hi, i am querying the DB as follows: $result=mysql_query("SELECT name,items FROM mytable WHERE user_id='$id'"); now,i want to create an array to insert the values that are as a result of this query e'g let's say this is the resultant data: n

Hi. i have a music samples website. in one table, id like a different sample to appear every time the page is refreshed. how do i acheve this? how can i alterate and retrieve these bloody mp3's? surely i can use a PHP script? thankyou



Custom Search