(移动目录)
if ( !empty( $testCategoryData) ) {
$data[0] = array_shift($testCategoryData);
$data[0]['children'] = $testCategoryData;
}
(移动用例)
$data = array();
$data[0]= $testCategoryData[0];
for ( $index = 1; $index < count($testCategoryData); $index++ ) {
$data[0]['children'][$index-1] = $testCategoryData[$index];
}
移动开发
php???
php
移动目录
------解决方案--------------------
for ( $index = 1; $index < count($testCategoryData); $index++ ) { //从下标1开始,直到最后
$data[0]['children'][$index-1] = $testCategoryData[$index]; //抄写每个元素到目标数组
}