Home Backend Development PHP Tutorial 数组有关问题,标题要长。

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

Jun 13, 2016 am 10:26 AM
array gt name

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

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$arr=array(                        array('name' =&gt; 'aa','id' =&gt; '456'),                        array('name' =&gt; 'bb','id' =&gt; '25',),                        array('name' =&gt; 'cc','id' =&gt; '25',),                        array('name' =&gt; 'dd','id' =&gt; '456',),                    );
Copy after login

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

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

PHP code
                                $newArr=array();                                foreach($deals_info as $key=&gt;$value){                                    if(!isset($newArr[$value['id']])){                                           $newArr[$value['id']][]=$value['name'];                                    }else{                                        foreach($newArr as $k=&gt;$v){                                            if($k==$value['id'] and !in_array($value['name'],$newArr[$k])){                                                    $newArr[$k][]=$value['name'];                                            }                                        }                                    }                                }<div class="clear">
                 
              
              
        
            </div>
Copy after login
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

What are the differences between Huawei GT3 Pro and GT4?

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Fix: Snipping tool not working in Windows 11

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

How to Fix Can't Connect to App Store Error on iPhone

Sort array using Array.Sort function in C# Sort array using Array.Sort function in C# Nov 18, 2023 am 10:37 AM

Sort array using Array.Sort function in C#

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决

Simple and clear method to use PHP array_merge_recursive() function Simple and clear method to use PHP array_merge_recursive() function Jun 27, 2023 pm 01:48 PM

Simple and clear method to use PHP array_merge_recursive() function

How to use the array_combine function in PHP to combine two arrays into an associative array How to use the array_combine function in PHP to combine two arrays into an associative array Jun 26, 2023 pm 01:41 PM

How to use the array_combine function in PHP to combine two arrays into an associative array

Detailed explanation of PHP array_fill() function usage Detailed explanation of PHP array_fill() function usage Jun 27, 2023 am 08:42 AM

Detailed explanation of PHP array_fill() function usage

See all articles