Diff
checker
文本
文本
图像
文档
Excel
文件夹
Legal
Enterprise
桌面版
定价
登录
下载 Diffchecker 桌面版
比较文本
查找两个文本文件之间的差异
工具
历史
实时编辑器
折叠未更改行
关闭换行
视图
拆分
统一
比对精度
智能
单词
字符
语法高亮
选择语法
忽略
文本转换
转到第一个差异
编辑输入
Diffchecker Desktop
运行Diffchecker最安全的方式。获取Diffchecker桌面应用:您的差异永远不会离开您的电脑!
获取桌面版
Untitled Diff
创建于
3年前
差异永不过期
清除
导出
分享
解释
20 删除
行
总计
删除
字符
总计
删除
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
23 行
全部复制
25 添加
行
总计
添加
字符
总计
添加
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
21 行
全部复制
<?php
<?php
复制
已复制
复制
已复制
// Turn an array into a key=>value
pair.
Assumes the key is the first item in the sub-array.
// Turn an array into a key=>value
or key=>array
pair.
public function column
_i
nto
_k
eys(array $array): array {
//
Assumes the key is the first item in the sub-array.
public function column
I
nto
K
eys(array $array): array {
// get the name of the column that contains the record id
$key = key($array[0]);
// skip empty arrays
if (! count($array)) return [];
// loop through each result row
foreach($array as $row) {
foreach($array as $row) {
复制
已复制
复制
已复制
// pop the
new key
off the top of the array
// pop the
value of the row identifier
off the top of the array
$id = array_shift($row);
$id = array_shift($row);
// O(n)
//
is
there
only one item left in the array
?
//
if
there
is
only one item left in the array
...
if
(count($row) == 1)
$result[$id] =
(count($row) == 1)
//
get the first value
? current($row)
//
...
get the first value
$result[$id] = current(
$row
);
:
$row
;
//
...
get
the rest
of the
array
else
//
get
all
of the
values
$result[$id] = $row;
}
}
复制
已复制
复制
已复制
return $result;
return $result;
}
}
已保存差异
原始文本
打开文件
<?php // Turn an array into a key=>value pair. Assumes the key is the first item in the sub-array. public function column_into_keys(array $array): array { // get the name of the column that contains the record id $key = key($array[0]); foreach($array as $row) { // pop the new key off the top of the array $id = array_shift($row); // is there only one item left in the array? if (count($row) == 1) // get the first value $result[$id] = current($row); else // get all of the values $result[$id] = $row; } return $result; }
更改后文本
打开文件
<?php // Turn an array into a key=>value or key=>array pair. // Assumes the key is the first item in the sub-array. public function columnIntoKeys(array $array): array { // skip empty arrays if (! count($array)) return []; // loop through each result row foreach($array as $row) { // pop the value of the row identifier off the top of the array $id = array_shift($row); // O(n) // if there is only one item left in the array... $result[$id] = (count($row) == 1) ? current($row) // ...get the first value : $row; // ...get the rest of the array } return $result; }
查找差异