php數(shù)組三維轉(zhuǎn)二維
創(chuàng)新互聯(lián)是一家專注網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷策劃、微信小程序、電子商務(wù)建設(shè)、網(wǎng)絡(luò)推廣、移動互聯(lián)開發(fā)、研究、服務(wù)為一體的技術(shù)型公司。公司成立十載以來,已經(jīng)為數(shù)千家建筑動畫各業(yè)的企業(yè)公司提供互聯(lián)網(wǎng)服務(wù)?,F(xiàn)在,服務(wù)的數(shù)千家客戶與我們一路同行,見證我們的成長;未來,我們一起分享成功的喜悅。
當(dāng)心,上代碼:
// 測試用的數(shù)組
$my_array = array (
'0'=>array(
'0'=>array('no'=>1212,'ret'=>'09'),
'1'=>array('no'=>1213,'ret'=>'09'),
'2'=>array('no'=>1214,'ret'=>'09'),
),
'1'=>array(
'0'=>array('no'=>1213,'ret'=>'10'),
'1'=>array('no'=>1214,'ret'=>'10'),
'2'=>array('no'=>1215,'ret'=>'10'),
),
);
$newhello=array();
$k = 0;
foreach ($my_array as $key => $val) {
foreach ($val as $key2 => $val2) {
$newhello[$k]['no'] = $val2['no'];
$newhello[$k]['ret'] = $val2['ret'];
$k++;
}
}
echo '';
print_r($my_array);
print_r($newhello);
exit();
打印運(yùn)行結(jié)果:
Array
(
[0] => Array
(
[0] => Array
(
[no] => 1212
[ret] => 09
)
[1] => Array
(
[no] => 1213
[ret] => 09
)
[2] => Array
(
[no] => 1214
[ret] => 09
)
)
[1] => Array
(
[0] => Array
(
[no] => 1213
[ret] => 10
)
[1] => Array
(
[no] => 1214
[ret] => 10
)
[2] => Array
(
[no] => 1215
[ret] => 10
)
)
)
Array
(
[0] => Array
(
[no] => 1212
[ret] => 09
)
[1] => Array
(
[no] => 1213
[ret] => 09
)
[2] => Array
(
[no] => 1214
[ret] => 09
)
[3] => Array
(
[no] => 1213
[ret] => 10
)
[4] => Array
(
[no] => 1214
[ret] => 10
)
[5] => Array
(
[no] => 1215
[ret] => 10
)
)