The PHP array has one-dimensional arrays and no arrays, and here we analyze the techniques of PHP's two-dimensional array ordering. PHP, a nested abbreviated name, is an abbreviation for the English Super Text preprocessing language (Php:hypertext preprocessor). PHP is an HTML embedded language, is a server-side implementation of embedded HTML document scripting language, language style has similar to the C language, is now widely used by many web site programmers. PHP's unique syntax mixes C, Java, Perl, and PHP's self-innovative syntax.
It can perform dynamic Web pages more quickly than CGI or Perl. Dynamic pages made with PHP are compared to other programming languages, and PHP is executed in an HTML document, which is much more efficient than CGI, which is also embedded in the HTML document, and PHP is executed on the server side, compared to the scripting language JavaScript Take full advantage of the performance of the server, the PHP execution engine will also be the user frequently access to the PHP program in memory, other users do not need to recompile the program once again to access the program, as long as the direct execution of in-memory code, which is the embodiment of PHP efficiency. PHP has a very powerful feature, all CGI or JavaScript functionality PHP can be implemented, and support almost all the popular database and operating system.
PHP two-dimensional array ordering uses the Asort function, but if a multidimensional array is sorted by one of the index values. In general, such a sort would introduce a temporary array to store intermediate variables such as key values by sorting the key to achieve a sort of multidimensional array. Here is a paragraph I wrote to sort by the time values in a two-dimensional array:
PHP two-dimensional array sorting code:
- php
- A two-dimensional array in descending order with the time inputdate as the key value
- function Array_sort ($arr, $keys, $type) {
- $ Keysvalue = Array ();
- $ I = 0 ;
- foreach ($arr as $key=>$val) {
- $val [$keys] = Str_replace ("-", "", $val [$keys]);
- $val [$keys] = Str_replace ("", "", $val [$keys]);
- $val [$keys] = Str_replace (":", "", $val [$keys]);
- $keysvalue [] = $val [$keys];
-
- }
- Asort ($keysvalue); Key value Sort
- Reset ($keysvalue); The pointer re-points to the first array of
- foreach ($keysvalue as $key=>$vals) {
- $keysort [] = $key;
- }
- $ New_array = Array ();
- if ($type! = "ASC") {
- For ($II=count($keysort)-1; $ii>= 0; $ ii--) {
- $new _array[] = $arr [$keysort [$ii]];
- }
- }else{
- For ($II=0; $ii<count($keysort ); $ii + +) {
- $new _array[] = $arr [$keysort [$ii]];
- }
- }
- return $new _array;
- }
- ?>
http://www.bkjia.com/PHPjc/446494.html www.bkjia.com true http://www.bkjia.com/PHPjc/446494.html techarticle the PHP array has one-dimensional arrays and no arrays, and here we analyze the techniques of PHP's two-dimensional array ordering. PHP, a nested abbreviated name, is the English Super Text preprocessing language (php:hy ...