当前位置:网站首页>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;
}
}
边栏推荐
- Apt command reports certificate error certificate verification failed: the certificate is not trusted
- js删除字符串的最后一个字符
- Error "list" object is not callable in Web automatic switching window
- Self study table Au
- js判断对象是否为空
- Anti shake and throttling of JS
- In depth study of JVM bottom layer (II): hotspot virtual machine object
- Deployment API_ automation_ Problems encountered during test
- CTF three count
- JS divides an array into groups of three
猜你喜欢
【文献阅读与想法笔记13】 Unprocessing Images for Learned Raw Denoising
Apt command reports certificate error certificate verification failed: the certificate is not trusted
查询GPU时无进程运行,但是显存却被占用了
PgSQL learning notes
sqli-labs通关汇总-page1
In depth study of JVM bottom layer (V): class loading mechanism
Fe - wechat applet - Bluetooth ble development research and use
Win电脑截图黑屏解决办法
Latex 报错 LaTeX Error: The font size command \normalsize is not defined问题解决
SQL injection closure judgment
随机推荐
[self cultivation of programmers] - Reflection on job hunting Part II
SQLI-LABS通关(less18-less20)
In depth study of JVM bottom layer (II): hotspot virtual machine object
Stack (linear structure)
Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance
Anti shake and throttling of JS
JS delete the last character of the string
ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package
Queue (linear structure)
[literature reading and thought notes 13] unprocessing images for learned raw denoising
微信小程序基础
Latex在VSCODE中编译中文,使用中文路径问题解决
[leetcode question brushing day 35] 1060 Missing element in ordered array, 1901 Find the peak element, 1380 Lucky number in matrix
In depth study of JVM bottom layer (IV): class file structure
Underlying mechanism mvcc
Latex参考文献引用失败 报错 LaTeX Warning: Citation “*****” on page y undefined on input line *
PIP install
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
CVE-2015-1635(MS15-034 )远程代码执行漏洞复现
QQ email cannot receive the email sent by Jenkins using email extension after construction (timestamp or auth...)