当前位置:网站首页>Two dimensional array de duplication in PHP
Two dimensional array de duplication in PHP
2022-07-02 07:28:00 【Snow wind in the night sky】
Preface
Sometimes in the database join When associating and querying data, some duplicate data will be found, which requires manual de duplication , Avoid returning to the list with duplicate data .
/** * 1. Delete the data of the same item in the two-dimensional array , It is generally used for de duplication of the same records in the database query results * 2. Reset the index of the two-dimensional array * @param array $_2d_array Two dimensional array , similar : * $tmpArr = array( * array('id' => 1, 'value' => '15046f5de5bb708e'), * array('id' => 1, 'value' => '15046f5de5bb708e'), * ); * @param string $unique_key Representing the above array "id" key , perhaps "value" key * @return mixed */
function unique_2d_array_by_key($_2d_array, $unique_key)
{
$tmp_key[] = array();
foreach ($_2d_array as $key => &$item) {
if (is_array($item) && isset($item[$unique_key])) {
if (in_array($item[$unique_key], $tmp_key)) {
unset($_2d_array[$key]);
} else {
$tmp_key[] = $item[$unique_key];
}
}
}
// Reset the index of the two-dimensional array
return array_slice($_2d_array, 0, count($_2d_array), false);
}
边栏推荐
- Get the uppercase initials of Chinese Pinyin in PHP
- Jordan decomposition example of matrix
- [paper introduction] r-drop: regulated dropout for neural networks
- 解决万恶的open failed: ENOENT (No such file or directory)/(Operation not permitted)
- Sparksql data skew
- Module not found: Error: Can't resolve './$$_ gendir/app/app. module. ngfactory'
- ORACLE APEX 21.2安裝及一鍵部署
- [Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge
- MySQL无order by的排序规则因素
- CONDA creates, replicates, and shares virtual environments
猜你喜欢

CSRF attack

ssm超市订单管理系统

How to efficiently develop a wechat applet
![[introduction to information retrieval] Chapter 3 fault tolerant retrieval](/img/75/ac2fdcd256f5c2336ca53c7a2744b8.png)
[introduction to information retrieval] Chapter 3 fault tolerant retrieval
![[tricks] whiteningbert: an easy unsupervised sentence embedding approach](/img/8e/3460fed55f2a21f8178e7b6bf77d56.png)
[tricks] whiteningbert: an easy unsupervised sentence embedding approach

Using compose to realize visible scrollbar
![[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge](/img/2e/e74d7a9efbf9fe617f4d7b46867c0a.png)
[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge

Cognitive science popularization of middle-aged people

Oracle EBS ADI development steps

使用Matlab实现:Jacobi、Gauss-Seidel迭代
随机推荐
[torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated
外币记账及重估总账余额表变化(下)
Feeling after reading "agile and tidy way: return to origin"
ssm人事管理系统
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'
ORACLE EBS中消息队列fnd_msg_pub、fnd_message在PL/SQL中的应用
parser. parse_ Args boolean type resolves false to true
Use matlab to realize: chord cut method, dichotomy, CG method, find zero point and solve equation
中年人的认知科普
DNS attack details
[introduction to information retrieval] Chapter II vocabulary dictionary and inverted record table
Proteus -- RS-232 dual computer communication
view的绘制机制(一)
SSM supermarket order management system
叮咚,Redis OM对象映射框架来了
SSM学生成绩信息管理系统
Interpretation of ernie1.0 and ernie2.0 papers
ssm+mysql实现进销存系统
Conda 创建,复制,分享虚拟环境
[torch] the most concise logging User Guide