数组有关问题,标题要长。

WBOY
Release: 2016-06-13 13:29:01
Original
1100 people have browsed it

请教大家数组问题,标题要长。。。

PHP code
<!--

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',),
                    );
Copy after login

怎么取出ID相同的name.提示出来。比如这个数组提示 aa 和 dd的id相同 ,bb 和 cc 的id相同

------解决方案--------------------
自己搞定了~!~

PHP code
                                $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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template