当前位置:网站首页>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]; //返回不相同的信息
}边栏推荐
- Record some small requirements in the form of cases
- 详解visual studio 2015在局域网中远程调试程序
- 第 7 篇:绘制旋转立方体
- 微信小程序开发公司你懂得选择吗?
- How to search images efficiently and accurately? Look at the lightweight visual pre training model
- HYDAC溢流阀DB08A-01-C-N-500V
- 为什么 0.1 + 0.2 不等于0.3?如何解决这个问题?
- Mesh data generation function meshgrid
- Versailles ceiling: "the monthly salary of two years after graduation is only 35K, which is really unpromising ~ ~"
- Nano gold coupled antibody / protein Kit (20nm, 1mg/100 μ g/500 μ G coupling amount) preparation
猜你喜欢

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 )

39. Combined sum

微信小程序开发公司你懂得选择吗?

Official document of kubevela 1.4.x

节省70%的显存,训练速度提高2倍!浙大&阿里提出在线卷积重新参数化OREPA,代码已开源!(CVPR 2022 )

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

Matlab | basic knowledge summary I

90. 子集 II

90. Subset II

Pytorch learning record (4): over fitting, convolution neural network CNN
随机推荐
基于Xception-TD的中华传统刺绣分类模型构建
基于复杂网络的大群体应急决策专家意见与信任信息融合方法及应用
Log slimming operation: how to optimize from 5g to 1g! (glory Collection Edition)
基于BRNN的政务APP评论端到端方面级情感分析方法
typeof原理
How to design workflow engine gracefully (glory Collection Edition)
What technology is needed for applet development
90. 子集 II
Open earphone which air conduction earphone with good sound quality and recognized sound quality is recommended
纳米金偶联抗体/蛋白试剂盒(20nm,1mg/100μg/500 μg偶联量)的制备
OA项目之会议通知(查询&是否参会&反馈详情)
fluke dtx-1800测试精度有必要进行原厂校准吗?
DHCP和PPPoE协议以及抓包分析
行内元素和块级元素有什么区别?语义化作用
Cy3/cy5/cy5.5/cy7 fluorescent labeling antibody / protein Kit (10~100mg labeling amount)
Pytoch learning record (III): random gradient descent, neural network and full connection
[machine learning] naive Bayesian classification of text -- Classification of people's names and countries
管理区解耦架构见过吗?能帮客户搞定大难题的
小程序开发需要什么技术
[hero planet July training leetcode problem solving daily] dynamic planning on the 28th