当前位置:网站首页>PHP method to get the index value of the array item with the largest key value in the array
PHP method to get the index value of the array item with the largest key value in the array
2022-07-02 15:07:00 【Lingering memory of Yu Fei】
php The method of getting the index value of the array item with the largest key value in the array
One 、 The problem background
Get the key value of the array item with the largest value from the given array . Uses such as : Get the name of the student with the highest score in the class .
Two 、 Solution
<?php
/* * created on 2022-qipa-250 * created by www.qipa250.com */
$arr=array('tom'=>9,'jack'=>3,'kim'=>5,'hack'=>4);
asort($arr);
//print_r($arr);
// Output :array ( [jack] => 3 [hack] => 4 [kim] => 5 [tom] => 9 )
$rel=array();
foreach($arr as $k=>$v){
$rel[]=$k;
}
//echo $rel[0];// Output min :jack
echo end($rel);// Output Max :tom
?>
边栏推荐
- 富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)
- 记一次面试
- Slashgear shares 2021 life changing technology products, which are somewhat unexpected
- 数据库内容输出有问题怎么解决
- 【题解】Educational Codeforces Round 82
- 学习使用php实现公历农历转换的方法代码
- Fundamentals of software testing
- 【无标题】LeetCode 2321. 拼接数组的最大分数
- Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
- TiDB 软件和硬件环境建议配置
猜你喜欢

btrace-(字节码)动态跟踪工具

富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)

Dragonfly low code security tool platform development path

How does CTO help the business?

【C语音】详解指针进阶和注意点(2)

LeetCode 2320. 统计放置房子的方式数

GeoServer offline map service construction and layer Publishing

Solve the problem that El radio group cannot be edited after echo

forEach的错误用法,你都学废了吗

【NOI模拟赛】刮痧(动态规划)
随机推荐
Record an error report, solve the experience, rely on repetition
【C语音】详解指针进阶和注意点(2)
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
[c voice] explain the advanced pointer and points for attention (2)
原则、语言、编译、解释
MathML to latex
fatal: unsafe repository is owned by someone else 的解决方法
871. 最低加油次数 : 简单优先队列(堆)贪心题
数据库内容输出有问题怎么解决
C#延时、在线程中开启定时器、获取系统时间
The past and present lives of visual page building tools
【题解】Educational Codeforces Round 82
【无标题】LeetCode 2321. 拼接数组的最大分数
Implementation of n queen in C language
Full of knowledge points, how to use JMeter to generate encrypted data and write it to the database? Don't collect it quickly
JMeter script parameterization
Base64 编码原来还可以这么理解
Slashgear shares 2021 life changing technology products, which are somewhat unexpected
TiDB混合部署拓扑
Sharp tool SPL for post SQL calculation