Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Sort an Array by Keys
How To Sort an Array by Keys? - PHP Script Tips - PHP Built-in Functions for Arrays
✍: FYIcenter.com
Sorting an array by keys can be done by using the ksort() function. It will re-order all pairs of keys and values based on the alphanumeric order of the keys. Here is a PHP script on how to use ksort():
<?php $mixed = array(); $mixed["Zero"] = "PHP"; $mixed[1] = "Perl"; $mixed["Two"] = "Java"; $mixed["3"] = "C+"; $mixed[""] = "Basic"; $mixed[] = "Pascal"; $mixed[] = "FORTRAN"; ksort($mixed); print("Sorted by keys:\n"); print_r($mixed); ?>
This script will print:
Sorted by keys: Array ( [] => Basic [Two] => Java [Zero] => PHP [1] => Perl [3] => C+ [4] => Pascal [5] => FORTRAN )
2007-04-21, 5281👍, 0💬
Popular Posts:
Enable ASP.NET polling using “web.config” file Now that all our database side is configured in order...
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...
Can you explain different software development life cycles -part II? Water Fall Model This is the ol...
What is the concept of XPOINTER? XPOINTER is used to locate data within XML document. XPOINTER can p...
How do we host a WCF service in IIS? Note: - The best to know how to host a WCF in IIS is by doing a...