当前位置:网站首页>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
?>
边栏推荐
- C # delay, start the timer in the thread, and obtain the system time
- CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
- C language exercises - (array)
- vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
- Table responsive layout tips
- 【apipost】使用教程
- Introduction to mathjax (web display of mathematical formulas, vector)
- MFC CString 转 char*
- Obsidian installs third-party plug-ins - unable to load plug-ins
- geoserver离线地图服务搭建和图层发布
猜你喜欢

Map介绍

Li Chuang EDA learning notes 15: draw border or import border (DXF file)

Obsidian installs third-party plug-ins - unable to load plug-ins

Dragonfly low code security tool platform development path

CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E

It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen

C code audit practice + pre knowledge

Socket and socket address

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

Full of knowledge points, how to use JMeter to generate encrypted data and write it to the database? Don't collect it quickly
随机推荐
Internet Explorer officially retired
C code audit practice + pre knowledge
C language exercises - (array)
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment
MFC timer usage
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
TiDB混合部署拓扑
Some Chinese character codes in the user privacy agreement are not standardized, which leads to the display of garbled codes on the web page. It needs to be found and handled uniformly
用户隐私协议有些汉字编码不规范导致网页显示乱码,需要统一找出来处理一下
[development environment] install the visual studio community 2013 development environment (download the installation package of visual studio community 2013 with update 5 version)
JMeter script parameterization
mathML转latex
btrace-(字节码)动态跟踪工具
[apipost] tutorial
XML配置文件
[noi Simulation Competition] scraping (dynamic planning)
Wechat applet uses towxml to display formula
Database connection pool and data source
Find the maximum inscribed circle of the contour
TiDB 软件和硬件环境建议配置