当前位置:网站首页>php中在二维数组中根据值返回对应的键值
php中在二维数组中根据值返回对应的键值
2022-07-02 06:23:00 【夜空の雪風】
前言
在进行数组操作的时候有时候需要根据数组中的值找寻对应的键值,这里分享一个方法,可以快速的根据二维数组中的值找寻对应的键值。
/** *根据值返回对于的key 键名 *@param $search[string] 搜索的值 *@param $array[array] 被搜索的数组 *@return 找到返回键名 未找到返回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;
}
}
边栏推荐
- 由于不正常断电导致的unexpected inconsistency;RUN fsck MANUALLY问题已解决
- 浏览器滚动加载更多实现
- JS create a custom JSON array
- Fe - eggjs combined with typeorm cannot connect to the database
- Sentry搭建和使用
- In depth study of JVM bottom layer (V): class loading mechanism
- Render minecraft scenes into real scenes using NVIDIA GPU
- 蚂蚁集团g6初探
- 2021-07-17C#/CAD二次开发创建圆(5)
- Sqli labs customs clearance summary-page4
猜你喜欢
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
Fe - wechat applet - Bluetooth ble development research and use
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
PHP Session原理简析
SQLI-LABS通关(less18-less20)
sqli-labs通关汇总-page1
Sqli - Labs Clearance (less6 - less14)
Sqli-labs customs clearance (less15-less17)
Sublime text configuring PHP compilation environment
CTF web practice competition
随机推荐
Self cultivation of programmers - Reflection on job hunting
SQLI-LABS通关(less1)
Virtualenv and pipenv installation
2020-9-23 use of QT timer qtimer class.
Win10: add or delete boot items, and add user-defined boot files to boot items
Latex error: the font size command \normalsize is not defined problem solved
Win10:添加或者删除开机启动项,在开机启动项中添加在用户自定义的启动文件
Improve user experience defensive programming
如何调试微信内置浏览器应用(企业号、公众号、订阅号)
Linux MySQL 5.6.51 Community Generic 安装教程
CVE-2015-1635(MS15-034 )远程代码执行漏洞复现
The table component specifies the concatenation parallel method
由于不正常断电导致的unexpected inconsistency;RUN fsck MANUALLY问题已解决
CTF three count
In depth study of JVM bottom layer (II): hotspot virtual machine object
Cve-2015-1635 (ms15-034) Remote Code Execution Vulnerability recurrence
Review of reflection topics
Linux MySQL 5.6.51 community generic installation tutorial
部署api_automation_test过程中遇到的问题
Vscode installation, latex environment, parameter configuration, common problem solving