PHP uses asort() to sort associative arrays by value, asort array_PHP tutorial

WBOY
Release: 2016-07-13 10:02:51
Original
792 people have browsed it

php uses asort() to sort associative arrays by value, asort array

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

PHP uses asort() to sort the associative array by value. The difference from sort is that sort assigns new key names to the cells in the array. The original key name will be deleted.

$nums = array("one"=>5,"two"=>2,"three"=>1);
asort( $nums );
foreach ( $nums 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/969490.htmlTechArticlephp uses asort() to sort associative arrays by value. The asort array example in this article describes how php uses asort() ) method to sort an associative array by value. Share it with everyone for your reference. ...
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