日期:2014-05-17 浏览次数:20464 次
<?php $arr = array(array(1,0),array(2,0),array(3,0),array(4,0),array(5,1),array(6,1),array(7,5),array(8,2)); ?>
<?php $arr = array(array(1,0),array(5,1),array(7,5),array(6,1),array(2,0),array(8,2),array(3,0),array(4,0)); ?>
$arr = array(array(1,0),array(2,0),array(3,0),array(4,0),array(5,1),array(6,1),array(7,5),array(8,2)); print_r(foo($arr)); function foo($ar, $p=0) { $r = array(); foreach($ar as $v) { if($v[1] == $p) { $r[] = $v; $r = array_merge($r, foo($ar, $v[0])); } } return $r; }