Home > Backend Development > PHP Tutorial > 恳求帮忙,php比较两个二维数组并按键排序查出重复值。

恳求帮忙,php比较两个二维数组并按键排序查出重复值。

WBOY
Release: 2016-06-13 12:37:41
Original
894 people have browsed it

恳请帮忙,php比较两个二维数组并按键排序查出重复值。。
示例如下:

<br />
$arr1=array(<br />
   0=>array('pid'=>1,name=>'user1'),<br />
   1=>array('pid'=>2,name=>'user2')<br />
);<br />
Copy after login

<br />
$arr2=array(<br />
   0=>array('pid'=>3,name=>'user1'),<br />
   1=>array('pid'=>4,name=>'user4')<br />
);<br />
Copy after login

我要得到下面这样的结果:
<br />
$arr2=array(<br />
   0=>array('pid'=>1,name=>'user1'),<br />
   1=>array('pid'=>2,name=>'user2')<br />
   2=>array('pid'=>3,name=>'user3'),<br />
   3=>array('pid'=>4,name=>'user4')<br />
);<br />
Copy after login

我要比较这两个数组并将重复值查出来按照pid排序,然后把pid大的那个重复user1改成user3
二维数组 php 排序

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