当前位置:网站首页>PHP returns the corresponding key value according to the value in the two-dimensional array
PHP returns the corresponding key value according to the value in the two-dimensional array
2022-07-02 07:28:00 【Snow wind in the night sky】
Preface
When performing array operations, you sometimes need to find the corresponding key value according to the value in the array , Here's a way to share , You can quickly find the corresponding key value according to the value in the two-dimensional array .
/** * Returns the for according to the value key Key name *@param $search[string] Search value *@param $array[array] Array searched *@return Find return key name No return found false */
function deep_get_key($search, $arr)
{
$index = '';
foreach ($arr as $value) {
foreach ($value as $k => $v) {
if ($v === $search) {
$index = $k;
break;
}
}
if ($index) {
break;
}
}
if (empty($index)) {
return false;
} else {
return $index;
}
}
边栏推荐
- Implement interface Iterable & lt; T>
- TCP attack
- 【信息检索导论】第三章 容错式检索
- A summary of a middle-aged programmer's study of modern Chinese history
- How to efficiently develop a wechat applet
- 自然辩证辨析题整理
- Classloader and parental delegation mechanism
- Oracle EBS interface development - quick generation of JSON format data
- 类加载器及双亲委派机制
- SSM supermarket order management system
猜你喜欢
Message queue fnd in Oracle EBS_ msg_ pub、fnd_ Application of message in pl/sql
A slide with two tables will help you quickly understand the target detection
view的绘制机制(一)
Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi
Error in running test pyspark in idea2020
Explain in detail the process of realizing Chinese text classification by CNN
Oracle EBS数据库监控-Zabbix+zabbix-agent2+orabbix
ssm人事管理系统
SSM supermarket order management system
点云数据理解(PointNet实现第3步)
随机推荐
Oracle RMAN semi automatic recovery script restore phase
实现接口 Interface Iterable<T>
Oracle EBS database monitoring -zabbix+zabbix-agent2+orabbix
Drawing mechanism of view (II)
[torch] the most concise logging User Guide
中年人的认知科普
Changes in foreign currency bookkeeping and revaluation general ledger balance table (Part 2)
Network security -- intrusion detection of emergency response
@Transitional step pit
spark sql任务性能优化(基础)
Huawei machine test questions
Check log4j problems using stain analysis
Using compose to realize visible scrollbar
PointNet理解(PointNet实现第4步)
Drawing mechanism of view (I)
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
解决万恶的open failed: ENOENT (No such file or directory)/(Operation not permitted)
ARP attack
传统目标检测笔记1__ Viola Jones
【信息检索导论】第七章搜索系统中的评分计算