Maison >développement back-end >tutoriel php >数组有关问题,标题要长。
请教大家数组问题,标题要长。。。
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$arr=array( array('name' => 'aa','id' => '456'), array('name' => 'bb','id' => '25',), array('name' => 'cc','id' => '25',), array('name' => 'dd','id' => '456',), );
$newArr=array(); foreach($deals_info as $key=>$value){ if(!isset($newArr[$value['id']])){ $newArr[$value['id']][]=$value['name']; }else{ foreach($newArr as $k=>$v){ if($k==$value['id'] and !in_array($value['name'],$newArr[$k])){ $newArr[$k][]=$value['name']; } } } }<div class="clear"> </div>