-
- $switching = array(
- 10, // key = 0
- 5 => 6,
- 3 => 7,
- 'a' => 4,
- 11, / / key = 6 (the maximum value of the integer key index in the entire array is 5)
- '8' => 2, // key = 8 (the string key '8' is converted to 8)
- '02' => 77, // key = '02' (note not 2)
- 0 => 12
- /*The previous key with a value of 10 is assigned 0, and later the value of the 0 key is redefined to 12,
- thus overwriting the previous one Default 0 key value */
- );
- // empty array
- $empty = array();
- ?>
-
Copy code
If printed with print_r($switching), the result is:
Array ( [0] => 12 [5] => 6 [3] => 7 [a] => 4 [6] => 11 [8] => 2 [02] => 77 )
Note that the two-digit number 02 is sorted behind.
|