时间:2021-07-01 10:21:17 帮助过:65人阅读
$a = array( Array ( 'tag' => 'id', 'type' => 'complete', 'level' => 4, 'value' => '01' ), Array ( 'tag' => 'name', 'type' => 'complete', 'level' => 4, 'value' => '小张' ), Array ( 'tag' => 'flag', 'type' => 'complete', 'level' => 4, ), Array ( 'tag' => 'id', 'type' => 'complete', 'level' => 4, 'value' => '02' ), Array ( 'tag' => 'name', 'type' => 'complete', 'level' => 4, 'value' => '小李' ), Array ( 'tag' => 'flag', 'type' => 'complete', 'level' => 4, ), Array ( 'tag' => 'id', 'type' => 'complete', 'level' => 4, 'value' => '03' ), Array ( 'tag' => 'name', 'type' => 'complete', 'level' => 4, 'value' => '小刘' ), Array ( 'tag' => 'flag', 'type' => 'complete', 'level' => 4, ),);$st = array();foreach($a as $t) { if(isset($st[$t['tag']])) { //完成你需要的操作 $st = array(); } $st[$t['tag']] = $t;}应该看得懂吧
我试了一下楼上的做法,稍微有点问题,我换了个方法,暂时解决了,不过也给你分吧,谁让你是唯一一个回答我问题的捏~~~