PHP contains numbers. Therefore, the subscript of the array starts from 0 by default and does not need to be specified. php automatically assigns an integer value to it and then auto-increment it. You can also specify the start subscript. For example:
$ Temp_number = array (2 => "one", "two", "three", "four ");
In this way, the four element values "one", "two", "three", and "four" are stored at the positions of key names 2, 3, 4, and 5. You can also specify the array key to save the array value. For example:
$ Temp_number = array (2 => "one", 4 => "two", 6 => "three ");
In this way, the values of the three array elements "one", "two", and "three" are saved at the positions of key names 2, 4, and 6.
Except for $ temp_number = array (2 => "one", "two", "three", "four"), this subscripts auto-increment exploitation method
In the for loop, you can also use the subscript auto-increment of numbers.
Foreach ($ target as $ key => $ value) {If (empty ($ value) continue; $ result [] = array ('cmd' => 'test ', 'param' => $ value );}
Result can be regarded as a two-dimensional array, which itself serves as an array, and its element is also an array
Of course, here we need to pay attention to the fact that the Code does not set a subscript for the array of result, it is completely using the auto-increment of the lower mark!