[php]
$items = array(
1 => array('id' => 1, 'pid' => 0, 'name' => '江西省')、
2 => array('id' => 2, 'pid' => 0, 'name' => '黒竜江省')、
3 => array('id' => 3, 'pid' => 1, 'name' => '南昌市')、
4 => array('id' => 4, 'pid' => 2, 'name' => 'ハルビン市'),
5 => array('id' => 5, 'pid' => 2, 'name' => '鶏西市'),
6 => array('id' => 6, 'pid' => 4, 'name' => 'Xiangfang District'),
7 => array('id' => 7, 'pid' => 4, 'name' => '南港区'),
8 => array('id' => 8, 'pid' => 6, 'name' => '六角路'),
9 => array('id' => 9, 'pid' => 7, 'name' => '西達街'),
10 => array('id' => 10, 'pid' => 8, 'name' => '東北林業大学'),
11 => array('id' => 11, 'pid' => 9, 'name' => 'ハルビン工業大学'),
12 => array('id' => 12, 'pid' => 8, 'name' => 'ハルビン師範大学'),
13 => array('id' => 13, 'pid' => 1, 'name' => '甘州市')、
14 => array('id' => 14, 'pid' => 13, 'name' => 'ガン郡')、
15 => array('id' => 15, 'pid' => 13, 'name' => '玉都県'),
16 => array('id' => 16, 'pid' => 14, 'name' => 'Maodian Town'),
17 => array('id' => 17, 'pid' => 14, 'name' => '大丹郷'),
18 => array('id' => 18, 'pid' => 16, 'name' => '宜源村'),
19 => array('id' => 19, 'pid' => 16, 'name' => 'シャンバ村'),
20 => array('id' => 20, 'pid' => 0, 'name' => '広東省'),
21 => array('id' => 21, 'pid' => 20, 'name' => '広州市')、
);
$t = 配列();
foreach ($items as $id => $item) {
if ($item['pid']) {
$items[$item['pid']][$item['id']] = &$items[$item['id']]
$t[] = $id
}
}
foreach($t as $u) {
unset($items[$u]);
}
エコー "";
print_r($items);
http://www.bkjia.com/PHPjc/477827.html
www.bkjia.com
本当http://www.bkjia.com/PHPjc/477827.html技術記事 [php] $items = array( 1 = array(id = 1, pid = 0, name = 江西省), 2 = array(id = 2, pid = 0, name = 黒竜江省), 3 = array(id = 3、pid = 1、名前 = 南昌市)、4 = array(id = 4、...)