当前位置:网站首页>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;
}
}
边栏推荐
- Virtualenv and pipenv installation
- js判断数组中对象是否存在某个值
- Self study table Au
- Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
- JS delete the last bit of the string
- [literature reading and thought notes 13] unprocessing images for learned raw denoising
- JS divides an array into groups of three
- The win10 network icon disappears, and the network icon turns gray. Open the network and set the flash back to solve the problem
- Blog directory of zzq -- updated on 20210601
- JS delete the last character of the string
猜你喜欢

Cve-2015-1635 (ms15-034) Remote Code Execution Vulnerability recurrence

sqli-labs通关汇总-page3

Latex在VSCODE中编译中文,使用中文路径问题解决

Sentry搭建和使用

SQL注入闭合判断

In depth study of JVM bottom layer (II): hotspot virtual machine object

unittest. Texttestrunner does not generate TXT test reports

ZZQ的博客目录--更新于20210601

PgSQL learning notes

Présence d'une panne de courant anormale; Problème de gestion de la fsck d'exécution résolu
随机推荐
Win10:添加或者删除开机启动项,在开机启动项中添加在用户自定义的启动文件
[daily question 1] write a function to judge whether a string is the string after the rotation of another string.
apt命令报证书错误 Certificate verification failed: The certificate is NOT trusted
默认google浏览器打不开链接(点击超链接没有反应)
flex九宫格布局
Common function writing method and set get writing method for calculating attributes
Queue (linear structure)
ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package
Brief analysis of PHP session principle
unittest. Texttestrunner does not generate TXT test reports
The default Google browser cannot open the link (clicking the hyperlink does not respond)
sqli-labs通关汇总-page3
Fe - wechat applet - Bluetooth ble development research and use
SQLI-LABS通关(less1)
Sqli labs customs clearance summary-page3
In depth study of JVM bottom layer (3): garbage collector and memory allocation strategy
Sqli-labs customs clearance (less18-less20)
VSCODE 安装LATEX环境,参数配置,常见问题解决
CAD二次开发 对象
Latex compiles Chinese in vscode and solves the problem of using Chinese path