dump($array);
array(2) { [0] => array(6) { ["record_id"] => string(1) "1" ["record_create_time"] => string(10) "1470650276" ["record_create_people"] => string(12) "測試人員" ["record_name"] => string(9) "vpn出售" ["record_comment"] => string(20) "出售10個包月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) "測試人員" ["record_name"] => string(9) "伺服器" ["record_comment"] => string(28) "雙核CPU2G記憶體40SDD硬碟" ["record_money"] => string(5) "15000" }}
我想改成這樣
array(2) { [0] => array(6) { ["0"] => string(1) "1" ["1"] => string(10) "1470650276" ["2"] => string(12) "測試人員" ["3"] => string(9) "vpn出售" ["4"] => string(20) "出售10個包月VPN" ["5"] => string(6) "100000" } [1] => array(6) { ["0"] => string(1) "2" ["1"] => string(10) "1470650739" ["2"] => string(12) "測試人員" ["3"] => string(9) "伺服器" ["4"] => string(28) "雙核CPU2G記憶體40SDD硬碟" ["5"] => string(5) "15000" }}
回複內容:
dump($array);
array(2) { [0] => array(6) { ["record_id"] => string(1) "1" ["record_create_time"] => string(10) "1470650276" ["record_create_people"] => string(12) "測試人員" ["record_name"] => string(9) "vpn出售" ["record_comment"] => string(20) "出售10個包月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) "測試人員" ["record_name"] => string(9) "伺服器" ["record_comment"] => string(28) "雙核CPU2G記憶體40SDD硬碟" ["record_money"] => string(5) "15000" }}
我想改成這樣
array(2) { [0] => array(6) { ["0"] => string(1) "1" ["1"] => string(10) "1470650276" ["2"] => string(12) "測試人員" ["3"] => string(9) "vpn出售" ["4"] => string(20) "出售10個包月VPN" ["5"] => string(6) "100000" } [1] => array(6) { ["0"] => string(1) "2" ["1"] => string(10) "1470650739" ["2"] => string(12) "測試人員" ["3"] => string(9) "伺服器" ["4"] => string(28) "雙核CPU2G記憶體40SDD硬碟" ["5"] => string(5) "15000" }}
鍵用"0"是被解析為數位。
相關文檔:http://php.net/manual/zh/lang...
你要轉換的話:
foreach($array as &item) { $item = array_values($item);}
案例代碼如下,你試試看
foreach($array as $key=>$val){ $array[$key] = array_values($val);}
array_values
"Bill","Age"=>"60","Country"=>"USA");print_r(array_values($a));?>