当前位置:网站首页>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
?>
边栏推荐
- Why can't programmers who can only program become excellent developers?
- JMeter script parameterization
- C语言中的printf函数和scanf函数
- 【C语言】详解指针的初阶和进阶以及注意点(1)
- About text selection in web pages and counting the length of selected text
- MFC CString to char*
- Xilinx Vivado set *. svh as SystemVerilog Header
- 学习使用php将时间戳转换为大写日期的方法代码示例
- 如何用 Sysbench 测试 TiDB
- Internet Explorer officially retired
猜你喜欢
[c voice] explain the advanced pointer and points for attention (2)
Onnx+tensorrt: write preprocessing operations to onnx and complete TRT deployment
vChain: Enabling Verifiable Boolean Range Queries over Blockchain Databases(sigmod‘2019)
.NET Core 日志系统
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
LeetCode - 搜索二维矩阵
Solve the problem that El radio group cannot be edited after echo
C code audit practice + pre knowledge
表格响应式布局小技巧
随机推荐
Map介绍
info [email protected]: The platform “win32“ is incompatible with this module.
[noi simulation] Elis (greedy, simulation)
Btrace- (bytecode) dynamic tracking tool
mathjax 入门(web显示数学公式,矢量的)
Introduction to mathjax (web display of mathematical formulas, vector)
实用调试技巧
TiDB 软件和硬件环境建议配置
C#延时、在线程中开启定时器、获取系统时间
Li Chuang EDA learning notes 15: draw border or import border (DXF file)
MFC CString 转 char*
taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
广州市应急管理局发布7月高温高湿化工安全提醒
Socket and socket address
Edit the formula with MathType, and set it to include only mathjax syntax when copying and pasting
kibana 基础操作
buuctf-pwn write-ups (7)
传感器数据怎么写入电脑数据库
C code audit practice + pre knowledge
Wechat applet uses towxml to display formula