当前位置:网站首页>PHP删除二维数组中相同项的数据
PHP删除二维数组中相同项的数据
2022-06-12 22:41:00 【码农竟在我身边】
//删除二维数组中相同项的数据
function array_2_unique($data, $unique_key_arr)
{
$arr = [];
if (!count($data)) {
return $arr;
}
array_push($arr, $data[0]);
foreach ($data as $v) {
$ex2 = true;
foreach ($arr as $value) {
$ex_arr = [];
foreach ($unique_key_arr as $v3) {
$ex = $value[$v3] == $v[$v3];
array_push($ex_arr, $ex);
}
if (!in_array(false, $ex_arr)) {
$ex2 = false;
}
}
if ($ex2) {
array_push($arr, $v);
}
}
return array_slice($arr, 0, count($arr), false);
}
//当room_id and user_id相等的时候删除
$data2 = array_2_unique($data2, ['room_id', 'user_id']);
边栏推荐
- JVM Basics - > What are the thread shared areas in the JVM
- Su embedded training day13 - file IO
- Market trend report, technical innovation and market forecast of Chinese stump crusher
- 【LeetCode】102. Sequence traversal of binary tree
- USB mechanical keyboard changed to Bluetooth Keyboard
- Alcohol detector based on 51 single chip microcomputer
- The programmer dedicated to promoting VIM has left. Father of vim: I will dedicate version 9.0 to him
- Afraid to write documents? AI plug-in for automatically generating code documents
- 42岁大厂高管,给30岁-39岁人提个醒:这6个让你变强的习惯,要尽快养成
- 反走样/抗锯齿技术
猜你喜欢

C # reading table data in word
![[data analysis] data clustering and grouping based on kmeans, including Matlab source code](/img/76/deec6cf60c0d02e99ebc3e21d3b8a4.png)
[data analysis] data clustering and grouping based on kmeans, including Matlab source code

Redis optimization

Audio and video technology development weekly 𞓜 234

The annual salary of 500000 is one line, and the annual salary of 1million is another line

【图像去噪】基于三边滤波器实现图像去噪附matlab代码

flutter系列之:flutter中常用的GridView layout详解

RAID disk array
![[Part 7] source code analysis and application details of cyclicbarrier [key]](/img/bc/8ba2b86e599539a29683a63d02f0f7.jpg)
[Part 7] source code analysis and application details of cyclicbarrier [key]

(downloadable) Research Report on the development and utilization of government data (2021), a glimpse of the development of Government Office
随机推荐
The development trend of digital collections!
認識的幾比特清華同學都離職了……
vim利用右下4键
China embolic coil market trend report, technical innovation and market forecast
【LeetCode】剑指 Offer II 020. 回文子字符串的个数
The carrying capacity of L2 level ADAS increased by more than 60% year-on-year in January, and domestic suppliers "emerged"
Huawei officially entered the "front loading" stage, and the millimeter wave radar track entered the "localization +4d" cycle
China's new generation information technology industry "14th five year plan" special planning and innovation strategic direction report 2022 ~ 2028
【LeetCode】33. Search rotation sort array
細數攻防演練中十大關鍵防守點
【LeetCode】103. Zigzag sequence traversal of binary tree
【LeetCode】300. Longest ascending subsequence
Market trend report, technical innovation and market forecast of Chinese stump crusher
【LeetCode】5. 最长回文子串
LNMP platform docking redis service
Redis optimization
Database system composition
[leetcode] the k-largest element in the array
JVM foundation > CMS garbage collector
How to perform disaster recovery and recovery for kubernetes cluster? (22)