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 can I sort an array keeping the correlation between the index and value?


If you want to do this, then it's time to think of 'a' for 'associative', and use this sort function rather than the regular sort function.

Otherwise it functions the same: asort($array);

<?php
$myworld 
= array("a"=>"php","b"=>"learning","c"=>"i'm");
asort($myworld);
print_r($myworld);
?>


Which prints:

Array
(
[c] => i'm
[b] => learning
[a] => php
)



ASK A QUESTION

More arrays PHP Questions

How can I reverse sort an array keeping the correlation between the index and value?

HOW CAN I DELETE ALL THE ELEMENT OF THE ARRAY

How can I display values in a two dimensional array?

in .$array->description doesn't work "description" is suppose to stay black and turns colored and is ignored Why?

How do I reverse sort the members of an array?



Custom Search