当前位置:网站首页>array_ diff_ The method of not comparing array values when Assoc element is an array
array_ diff_ The method of not comparing array values when Assoc element is an array
2022-07-28 22:07:00 【Seven five eight one six】
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])) {
// It's all arrays
if (count($value) == count($arg[$key])) {
// Equal quantity and depth comparison
$diff = array_diff_deep($value, $arg[$key]);
if ($diff) {
array_push($droped, $key);
}
} else {
// Unequal quantity directly negates
array_push($droped, $key);
}
} else {
if (is_numeric($value) && is_numeric($arg[$key])) {
// They are all numbers, not types, only ratios
if ($value != $arg[$key]) {
array_push($droped, $key);
}
} else {
// Other cases compare types and values
if ($value !== $arg[$key]) {
array_push($droped, $key);
}
}
}
}
}
}
return array_columns([$array], $droped)[0]; // Return different information
}边栏推荐
- Oracle built-in functions
- [NLP] generate word cloud
- 【机器学习】朴素贝叶斯对文本分类--对人名国别分类
- ESP8266-Arduino编程实例-定时器与中断
- How is nanoid faster and more secure than UUID implemented? (glory Collection Edition)
- B+ tree height calculation of MySQL
- display 各值的区别
- An end-to-end aspect level emotion analysis method for government app reviews based on brnn
- The difference between get and post
- Matlab | basic knowledge summary I
猜你喜欢

如何在 Web3中建立一个去中心化社区

Gateway technology of IOT technology stack

网格数据生成函数meshgrid

Information fusion method and application of expert opinion and trust in large group emergency decision-making based on complex network

kubevela插件addons下载地址

For the first time, Chinese scientists used DNA to construct convolutional artificial neural network, which can complete 32 types of molecular pattern recognition tasks, or be used for biomarker signa

Kubeedge releases white paper on cloud native edge computing threat model and security protection technology

Versailles ceiling: "the monthly salary of two years after graduation is only 35K, which is really unpromising ~ ~"

Apifox:满足你对 Api 的所有幻想

拥抱开源指南
随机推荐
HYDAC溢流阀DB08A-01-C-N-500V
Log slimming operation: how to optimize from 5g to 1g! (glory Collection Edition)
04. Default value of toref
Getting started with Oracle
Is it necessary to calibrate the fluke dtx-1800 test accuracy?
get和post的区别
What is a prime factor? In number theory, a prime factor (prime factor or prime factor) refers to a prime number that can divide a given positive integer
使用Mock技术帮助提升测试效率的小tips,你知道几个?
微信小程序开发入门,自己开发小程序
Principle of object. Prototype. ToString. Call()
株洲市九方中学开展防溺水、消防安全教育培训活动
Have you ever seen this kind of dynamic programming -- the stock problem of state machine dynamic programming (Part 2)
Esp8266 Arduino programming example - SPIFs and data upload (Arduino IDE and platformio IDE)
Matlab | basic knowledge summary I
Gateway technology of IOT technology stack
Desai wisdom number - line chart (stacking area chart): ranking of deposits of different occupational groups in the proportion of monthly income in 2022
迪赛智慧数——折线图(堆叠面积图):2022年不同职业人群存款额占月收入比例排名
Cross domain transfer learning of professional skill word extraction in Chinese recruitment documents
Oracle, SQL Foundation
小程序 canvas 生成海报