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

i need to store a multi-dimensioned array into a file. there is plenty of info. on creating md-arrays but i cant find anything on writing a md-array to a file.

how do i send the information from one page to another page using post method.

How do I change: function wordlimit($string, $length = 50, $ellipsis = "...") { $words = explode(' ', strip_tags($string)); if (count($words) > $length) return implode(' ', array_slice($words, 0, $length)) . $ellipsis; else

How may I keyboard replace the value of one cell of the array and the save that row to MySQL using PHP ?

How can I sort a multi-dimensional array?



Custom Search