当前位置:网站首页>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
?>
边栏推荐
- Reuse and distribution
- 数据库内容输出有问题怎么解决
- Why can't programmers who can only program become excellent developers?
- 哈夫曼树:(1)输入各字符及其权值(2)构造哈夫曼树(3)进行哈夫曼编码(4)查找HC[i],得到各字符的哈夫曼编码
- Bit by bit of OpenCV calling USB camera
- Mfc a dialog calls B dialog function and passes parameters
- Large top heap, small top heap and heap sequencing
- HUSTPC2022
- Solve the problem that El radio group cannot be edited after echo
- 使用 TiUP 部署 TiDB 集群
猜你喜欢

Large top heap, small top heap and heap sequencing
![[C language] explain the initial and advanced levels of the pointer and points for attention (1)](/img/61/1619bd2e959bae1b769963f66bab4e.png)
[C language] explain the initial and advanced levels of the pointer and points for attention (1)

About text selection in web pages and counting the length of selected text

Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.

Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)

为什么只会编程的程序员无法成为优秀的开发者?

Reuse and distribution

Wechat applet uses towxml to display formula

Introduction to C language -- array

Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
随机推荐
二叉树的遍历方式主要有:先序遍历、中序遍历、后序遍历、层次遍历。先序、中序、后序其实指的是父节点被访问的次序。若在遍历过程中,父节点先于它的子节点被访问,就是先序遍历;
AtCoder Beginner Contest 254
info [email protected]: The platform “win32“ is incompatible with this module.
Slashgear shares 2021 life changing technology products, which are somewhat unexpected
Key points of compilation principle examination in 2021-2022 academic year [overseas Chinese University]
Yolov6 training: various problems encountered in training your dataset
Advanced C language (realize simple address book)
Actual combat sharing of shutter screen acquisition
Huawei interview question: no palindrome string
C语言习题---(数组)
Btrace- (bytecode) dynamic tracking tool
C RichTextBox controls the maximum number of lines displayed
C language exercises - (array)
Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
[apipost] tutorial
Have you learned the wrong usage of foreach
taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
LeetCode 2310. The number of digits is the sum of integers of K
Socket and socket address
LeetCode 2310. 个位数字为 K 的整数之和