PHP uses the ksort() function to sort an associative array by key, ksort array_PHP tutorial

WBOY
Release: 2016-07-13 10:02:50
Original
1096 people have browsed it

php uses the ksort() function to sort associative arrays by key, ksort array

This article describes the example of php using the ksort() function to sort associative arrays by key . Share it with everyone for your reference. The specific analysis is as follows:

php uses the ksort() function to sort the associative array by key. The ksort function sorts the associative array in positive order by the keys. If you want to reverse the order, you can use the krsort() function

$first = array("x"=>5,"a"=>2,"f"=>1);
ksort( $first );
foreach ( $first as $key => $val ) {
 print "$key = $val<br />";
}
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969492.htmlTechArticlephp uses the ksort() function to sort associative arrays by key. The ksort array example in this article describes how php uses ksort The () function sorts an associative array by key. Share it with everyone...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!