当前位置:网站首页>array_diff_assoc 元素是数组时不比较数组值的办法
array_diff_assoc 元素是数组时不比较数组值的办法
2022-07-28 20:22:00 【柒伍伍捌壹陆】
function array_columns(array $array, $column_keys = [], $index_key = null) {
if ($column_keys && is_array($column_keys)) {
$newArray = [];
foreach ($column_keys as $c => $column_key) {
$tempArrs = array_column($array, $column_key, $index_key);
foreach ($tempArrs as $t => $tempArr) {
$newArray[$t][$column_key] = $tempArr;
}
}
return $newArray;
} else {
return [];
}
}
function array_diff_deep() {
$args = func_get_args();
$array = array_shift($args);
$droped = [];
foreach ($array as $key => $value) {
if (!in_array($key, $droped)) {
foreach ($args as $a => $arg) {
if (is_array($value) && is_array($arg[$key])) {
//都是数组
if (count($value) == count($arg[$key])) {
//数量相等深度对比
$diff = array_diff_deep($value, $arg[$key]);
if ($diff) {
array_push($droped, $key);
}
} else {
//数量不等直接否定
array_push($droped, $key);
}
} else {
if (is_numeric($value) && is_numeric($arg[$key])) {
//都是数字不比类型只对比值
if ($value != $arg[$key]) {
array_push($droped, $key);
}
} else {
//其他情况比较类型和值
if ($value !== $arg[$key]) {
array_push($droped, $key);
}
}
}
}
}
}
return array_columns([$array], $droped)[0]; //返回不相同的信息
}边栏推荐
- Byte side: can TCP and UDP use the same port?
- Skiasharp's WPF self drawn drag ball (case version)
- Leetcode 142. circular linked list II [knowledge points: speed pointer, hash table]
- 科大讯飞笔试
- Pytorch learning record (4): over fitting, convolution neural network CNN
- RHCSA第一天
- Which brand is the best and most cost-effective open headset
- Apple M1 processor details: performance and energy efficiency have doubled, and Intel Core i9 is no match!
- 90. Subset II
- Two global variables__ Dirname and__ Further introduction to common functions of filename and FS modules
猜你喜欢

Professional Committee of agricultural water and soil engineering of China Association of Agricultural Engineering - 12th session - Notes

Is it necessary to calibrate the fluke dtx-1800 test accuracy?

如何高效、精准地进行图片搜索?看看轻量化视觉预训练模型

Pyqt5 rapid development and actual combat 5.4 web page interaction

数据插值——对不同量级的数据进行归一化

基于多模态融合的非遗图片分类研究

Save 70% of the video memory and increase the training speed by 2 times! Zheda & Ali proposed online convolution re parameterization orepa, and the code has been open source! (CVPR 2022 )

kali里的powersploit、evasion、weevely等工具的杂项记录

Matlab from introduction to mastery Chapter 1 Introduction to matlab

Two global variables__ Dirname and__ Further introduction to common functions of filename and FS modules
随机推荐
Soft test --- database (3) data operation
Lt7911d type-c/dp to Mipi scheme is mature and can provide technical support
科大讯飞笔试
Zhuzhou Jiufang middle school carried out drowning prevention and fire safety education and training activities
基于属性词补全的武器装备属性抽取研究
HCIA comprehensive experiment (take Huawei ENSP as an example)
分而治之,大型文件分片上传
Apifox:满足你对 Api 的所有幻想
04.toRef 默认值
小程序 canvas 生成海报
基于复杂网络的大群体应急决策专家意见与信任信息融合方法及应用
Open earphone which air conduction earphone with good sound quality and recognized sound quality is recommended
腾讯云数据库负责人借了一亿元炒股?知情人士:金额不实
小程序开发需要什么技术
DHCP和PPPoE协议以及抓包分析
Oracle triggers
Gateway technology of IOT technology stack
标准C语言学习总结10
Matlab|基础知识总结一
I have been in the industry for 4 years and changed jobs twice. I have understood the field of software testing~