PHP after a long period of development, many users are very familiar with PHP, here I publish a personal understanding of the PHP array sorting, and we discuss the discussion. PHP is a server-side scripting language that is easy to learn and use. With minimal programming knowledge, you can use PHP to build a truly interactive web site. This tutorial does not want you to fully understand the language, but it will allow you to join the development of dynamic Web sites as soon as possible. I assume you have some basic knowledge of HTML (or HTML editor) and some programming ideas.
PHP Web files are treated as normal HTML Web files and you can write PHP in the usual way of editing HTML when editing. PHP representative: Hypertext Preprocessor (Php:hypertext preprocessor). PHP is completely free of charge and you can download it freely from the official PHP site (http://www.php.net). PHP complies with the GNU Public License (GPL), under which many popular software such as Linux and Emacs have been created. You can gain unlimited access to the source code and even add the features you need. PHP works on most Unix platforms, Gun/linux and Microsoft Windows platforms. Having said so much, let's talk about the ordering of PHP arrays.
PHP Array Sorting code:
- php
- $ arr = Array (5=>"Zero",3=>"One", 4=>"one");//define an array
- Sort ($arr);//Use sort to sort array
- foreach ($arras $key=>$value)//Iterate through the array to view the sorted results
- {
- echo "Key: $key; Value: $value; ";
- }
- ?>
- php
- Define an array
- $ arr = Array (5=>"Zero",3=> "One", 4 = > "both");
- Using Rsort to sort arrays
- Rsort ($arr);
- Iterating an array to see the sorted results
- foreach ($arras $key=>$value) {
- echo "Key: $key; Value: $value; ";
- }
- ?>
- php
- Define 2 arrays
- $ ar1 = Array (5=>"Zero",3=>"One", 4=>"both");
- $ ar2 = Array (4=>"Three",9=> "Four", 1 = > "Five");
- Sorting an array
- Array_multisort ($ar 1, $ar 2);
- Iterating an array to see the sorted results
- foreach ($ar 1as$key=>$value) {
- echo "Key: $key; Value: $value; ";
- }
- echo " <BR> ";
- foreach ($ar 2as$key=>$value) {
- echo "Key: $key; Value: $value; ";
- }
- ?>
- php
- Define a two-dimensional array
- $ Array Array =array ("ar1" =>Array (5=>, 3 = > , 4 = > ),
- "AR2" = > Array (4=>"Three",9=>" Four ",1=>" Five "));
- Sorting an array
- Array_multisort ($array ["Ar1"],sort_numeric,sort_desc,
- $array ["Ar2"],SORT_STRING,SORT_ASC);
- Iterating an array to see the sorted results
- foreach ($arrayas $v1)
- {
- foreach ($v 1as$v2)
- {
- echo "$v 2n";
- }
- }
- ?>
http://www.bkjia.com/PHPjc/446536.html www.bkjia.com true http://www.bkjia.com/PHPjc/446536.html techarticle PHP After a long period of development, many users are very familiar with PHP, here I publish a personal understanding of the PHP array sorting, and we discuss the discussion. PHP is an easy to learn and use server ...