当前位置:网站首页>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
}边栏推荐
猜你喜欢

Getting started with Oracle

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

【NLP】生成词云

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

Data interpolation -- normalize data of different magnitude

罗克韦尔AB PLC RSLogix数字量IO模块基本介绍

KubeEdge发布云原生边缘计算威胁模型及安全防护技术白皮书

Zhuzhou Jiufang middle school carried out drowning prevention and fire safety education and training activities

Make trouble fishing day by day

KubeVela 1.4.x 官方文档
随机推荐
Knowledge description framework of foreign patent documents based on knowledge elements
Getting started with Oracle
Nano gold coupled antibody / protein Kit (20nm, 1mg/100 μ g/500 μ G coupling amount) preparation
表单验证和级联下拉列表(多种实现)
Storage and steps of phospholipid coupled antibody / protein Kit
The applet listens for the target node to appear on the screen
科大讯飞笔试
腾讯云数据库负责人借了一亿元炒股?知情人士:金额不实
Matlab|基础知识总结一
Log slimming operation: how to optimize from 5g to 1g! (glory Collection Edition)
第 8 篇:创建摄像机类
Openeuler embedded sig | distributed soft bus
array_diff_assoc 元素是数组时不比较数组值的办法
KubeVela 1.4.x 官方文档
ESP8266-Arduino编程实例-SPIFFS及数据上传(Arduino IDE和PlatformIO IDE)
II. Explanation of the sequence and deserialization mechanism of redistemplate
Meeting notice of OA project (Query & whether to attend the meeting & feedback details)
迪赛智慧数——折线图(堆叠面积图):2022年不同职业人群存款额占月收入比例排名
Introduction to C language [detailed]
Principle of object. Prototype. ToString. Call()