PHP uses keys to sort two-dimensional arrays. PHP arrays have one-dimensional arrays instead of arrays. here we will analyze the PHP 2D array sorting techniques. PHP, an abbreviated name for nesting, is an English super Text preprocessing language (PHP: Hy PHP array has a one-dimensional array and not an array. here we will analyze the PHP 2D array sorting technique. PHP, an abbreviated name for nesting, is the abbreviation of the English Super Text preprocessing language (PHP: Hypertext Preprocessor. PHP is an embedded HTML language. it is a scripting language that executes HTML documents embedded on the server. the language style is similar to the C language, it is widely used by many website programmers. The unique PHP syntax is a mix of C, Java, Perl, and PHP self-innovative syntaxes.
It can execute dynamic web pages more quickly than CGI or Perl. Compared with other programming languages, PHP embeds programs into HTML documents for execution. the execution efficiency is much higher than the CGI that generates HTML tags completely; compared with the scripting language JavaScript, which is also embedded in HTML documents, PHP is executed on the server, making full use of the server performance; the PHP execution engine also stores PHP programs frequently accessed by users in the memory. when other users access this program again, they do not need to re-compile the program, you only need to directly execute the code in the memory, which is also one of the efficient implementations of PHP. PHP has very powerful functions, all CGI or JavaScript functions can be implemented in PHP, and supports almost all popular databases and operating systems.
PHP uses the asort function to sort two-dimensional arrays. However, if multi-dimensional arrays are sorted by an index value. In general, such sorting will introduce temporary arrays to store intermediate variables. for example, key values can be sorted by Keys to sort multi-dimensional arrays. The following section is sorted by the time value in the two-dimensional array:
PHP 2D array sorting code:
- Php
- // Sort two-dimensional arrays 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); // Sort key values
- Reset ($ keysvalue); // The pointer points to the first array.
- 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;
- }
- ?>
Bytes. PHP, an abbreviated name for nesting, is an English super Text preprocessing language (PHP: Hy...