Array(2) { [0] = =Array(6) { [0] = =string(1) "1" [1] = =string(10) "1470650276" [2] = =string(12) "Test personnel" [3] = =string(9) "VPN For Sale" [4] = =string(20) "Sale of 10 monthly VPN" [5] = =string(6) "100000" } [1] = =Array(6) { [0] = =string(1) "2" [1] = =string(10) "1470650739" [2] = =string(12) "Test personnel" [3] = =string(9) "Server" [4] = =string(28) "Dual core cpu2g memory 40SDD HDD" [5] = =string(5) "15000" }}
Change into
Array(2) { [0] = =Array(6) { ["record_id"] = =string(1) "1" ["Record_create_time"] = =string(10) "1470650276" ["Record_create_people"] = =string(12) "Test personnel" ["Record_name"] = =string(9) "VPN For Sale" ["Record_comment"] = =string(20) "Sale of 10 monthly VPN" ["Record_money"] = =string(6) "100000" } [1] = =Array(6) { ["record_id"] = =string(1) "2" ["Record_create_time"] = =string(10) "1470650739" ["Record_create_people"] = =string(12) "Test personnel" ["Record_name"] = =string(9) "Server" ["Record_comment"] = =string(28) "Dual core cpu2g memory 40SDD HDD" ["Record_money"] = =string(5) "15000" }}
The Array_combine () function creates a new array by merging two arrays, one of which is the key name and the value of the other array is the key value.
Note: Key an array groups and key-value arrays must have the same number of elements!
If one of the arrays is empty, or if the number of elements in the two array is different, the function returns FALSE.
$key=Array(' A ', ' B ', ' C ', ' d ');$array 1=Array(' 0 ' + =Array(' 0 ' + ' first ', ' 1 ' = ' + ', ' 2 ' = ' hp ', ' 3 ' + ' AAA '), ' 1 ' =Array(' 0 ' + ' first ', ' 1 ' = ' + ', ' 2 ' = ' hp ', ' 3 ' = ' aaa ')));foreach($array 1 as $kay=$val ){ $array 1[$kay] =Array_combine($key,$val);}Var_dump($array 1);
PHP array_combine changes the default key of the array to the specified string