移动开发 php php 移动目录
(移动目录)
if ( !empty( $testCategoryData) ) {
$data[0] = array_shift($testCategoryData);
$data[0]['children'] = $testCategoryData;
}
(移动用例)
$data = array();
$data[0]= $testCategoryData[0];
for ( $index = 1; $index $data[0]['children'][$index-1] = $testCategoryData[$index];
}
回复讨论(解决方案)
区别在于后者费时费力
能不能把后者for后面的处理原理给说一下,我一直用的是第一种方法,第二种是偶尔看到的,谢谢了
for ( $index = 1; $index $data[0]['children'][$index-1] = $testCategoryData[$index]; //抄写每个元素到目标数组
}
领教了,谢谢。
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn