时间:2021-07-01 10:21:17 帮助过:15人阅读
$data = array(
array('id' => 1,'pid' => 0,'name' => 'a'),
array('id' => 2,'pid' => 0,'name' => 'b'),
array('id' => 3,'pid' => 1,'name' => 'c'),
array('id' => 4,'pid' => 1,'name' => 'd'),
array('id' => 5,'pid' => 3,'name' => 'e'),
array('id' => 6,'pid' => 3,'name' => 'f'),
array('id' => 7,'pid' => 6,'name' => 'g'),
array('id' => 8,'pid' => 6,'name' => 'h'),
array('id' => 9,'pid' => 8,'name' => 'i'),
array('id' => 10,'pid' => 8,'name' => 'j'),
array('id' => 11,'pid' => 9,'name' => 'l'),
array('id' => 12,'pid' => 9,'name' => 'm'),
);
$data = array(
array('id' => 1,'pid' => 0,'name' => 'a'),
array('id' => 2,'pid' => 0,'name' => 'b'),
array('id' => 3,'pid' => 1,'name' => 'c'),
array('id' => 4,'pid' => 1,'name' => 'd'),
array('id' => 5,'pid' => 3,'name' => 'e'),
array('id' => 6,'pid' => 3,'name' => 'f'),
array('id' => 7,'pid' => 6,'name' => 'g'),
array('id' => 8,'pid' => 6,'name' => 'h'),
array('id' => 9,'pid' => 8,'name' => 'i'),
array('id' => 10,'pid' => 8,'name' => 'j'),
array('id' => 11,'pid' => 9,'name' => 'l'),
array('id' => 12,'pid' => 9,'name' => 'm'),
);
/********我是YD的分割线*************/
$pid = 1000000;
//$mark = 'c';
foreach ($data as $key => $value){
if ($value[pid] == $pid) {