数组有关问题,标题要长。
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' => '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
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
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

What are the differences between Huawei GT3 Pro and GT4?

Fix: Snipping tool not working in Windows 11

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

Sort array using Array.Sort function in C#

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

Detailed explanation of PHP array_fill() function usage
