当前位置:网站首页>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
?>
边栏推荐
- 用户隐私协议有些汉字编码不规范导致网页显示乱码,需要统一找出来处理一下
- Ad20 cannot select the solution of component packaging in PCB editor
- Why can't browsers read JSX?
- Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
- [QNX hypervisor 2.2 user manual]6.3 communication between guest and external
- Add vector formula in rich text editor (MathType for TinyMCE, visual addition)
- Base64 coding can be understood this way
- geoserver离线地图服务搭建和图层发布
- MathML to latex
- Sharp tool SPL for post SQL calculation
猜你喜欢

Add vector formula in rich text editor (MathType for TinyMCE, visual addition)

LeetCode 2310. 个位数字为 K 的整数之和
![[apipost] tutorial](/img/f9/717908a72720f152ad49034be64b35.png)
[apipost] tutorial

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

Jenkins Pipeline 应用与实践

kibana 基础操作

Map介绍

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

电脑怎么设置扬声器播放麦克风的声音

Base64 coding can be understood this way
随机推荐
TiDB 集群最小部署的拓扑架构
牛客练习赛101
如何用 Sysbench 测试 TiDB
學習使用php實現公曆農曆轉換的方法代碼
LeetCode 2310. The number of digits is the sum of integers of K
学习使用php实现公历农历转换的方法代码
taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
【题解】Educational Codeforces Round 82
Mavn 搭建 Nexus 私服
XML配置文件
Printf function and scanf function in C language
Internet Explorer officially retired
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
MFC 定时器使用
[untitled] leetcode 2321 Maximum score of concatenated array
【C语音】详解指针进阶和注意点(2)
N皇后问题的解决
taobao. trade. Get (get some information of a single transaction), Taobao store order interface, Taobao oauth2.0 interface, Taobao R2 interface code docking and sharing
LeetCode_滑动窗口_中等_395.至少有 K 个重复字符的最长子串
Obsidian installs third-party plug-ins - unable to load plug-ins