当前位置:网站首页>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;
}
}
边栏推荐
- 自然辩证辨析题整理
- Three principles of architecture design
- oracle apex ajax process + dy 校验
- Huawei machine test questions
- A slide with two tables will help you quickly understand the target detection
- 优化方法:常用数学符号的含义
- Module not found: Error: Can't resolve './$$_ gendir/app/app. module. ngfactory'
- JSP智能小区物业管理系统
- Interpretation of ernie1.0 and ernie2.0 papers
- Alpha Beta Pruning in Adversarial Search
猜你喜欢

使用 Compose 实现可见 ScrollBar

JSP智能小区物业管理系统

Illustration of etcd access in kubernetes

点云数据理解(PointNet实现第3步)

类加载器及双亲委派机制

Pratique et réflexion sur l'entrepôt de données hors ligne et le développement Bi

【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization

生成模型与判别模型的区别与理解

oracle apex ajax process + dy 校验

【Ranking】Pre-trained Language Model based Ranking in Baidu Search
随机推荐
一份Slide两张表格带你快速了解目标检测
JSP intelligent community property management system
Oracle EBS interface development - quick generation of JSON format data
【信息检索导论】第二章 词项词典与倒排记录表
ssm人事管理系统
One field in thinkphp5 corresponds to multiple fuzzy queries
Spark SQL task performance optimization (basic)
【Torch】最简洁logging使用指南
【MEDICAL】Attend to Medical Ontologies: Content Selection for Clinical Abstractive Summarization
@Transational踩坑
[torch] the most concise logging User Guide
[Bert, gpt+kg research] collection of papers on the integration of Pretrain model with knowledge
sparksql数据倾斜那些事儿
【BERT,GPT+KG调研】Pretrain model融合knowledge的论文集锦
oracle-外币记账时总账余额表gl_balance变化(上)
SSM实验室设备管理
【信息检索导论】第一章 布尔检索
Error in running test pyspark in idea2020
Play online games with mame32k
[torch] some ideas to solve the problem that the tensor parameters have gradients and the weight is not updated