当前位置:网站首页>php获取数组中键值最大数组项的索引值的方法
php获取数组中键值最大数组项的索引值的方法
2022-07-02 11:56:00 【徊忆羽菲】
一、问题背景
从给定数组中获取值最大的数组项的键值。用途如:获取班级得分最高的学生的姓名。
二、解决方案
<?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);
//输出:array ( [jack] => 3 [hack] => 4 [kim] => 5 [tom] => 9 )
$rel=array();
foreach($arr as $k=>$v){
$rel[]=$k;
}
//echo $rel[0];//输出最小值:jack
echo end($rel);//输出最大值:tom
?>
边栏推荐
- C# 线程传参
- PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
- [QNX Hypervisor 2.2用户手册]6.3 Guest与外部之间通信
- Threejs controller cube space basic controller + inertia control + flight control
- Jenkins Pipeline 应用与实践
- Ad20 cannot select the solution of component packaging in PCB editor
- jmeter脚本参数化
- Li Chuang EDA learning notes 15: draw border or import border (DXF file)
- GeoServer offline map service construction and layer Publishing
- YoloV6训练:训练自己数据集遇到的各种问题
猜你喜欢
![[apipost] tutorial](/img/f9/717908a72720f152ad49034be64b35.png)
[apipost] tutorial

Introduction to mathjax (web display of mathematical formulas, vector)
![[untitled] leetcode 2321 Maximum score of concatenated array](/img/a3/54d0e83f02ef0d0d8d269351c35b39.png)
[untitled] leetcode 2321 Maximum score of concatenated array

GeoServer offline map service construction and layer Publishing

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

Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)

MFC 定时器使用

socket(套接字)与socket地址

【NOI模拟赛】刮痧(动态规划)

. Net core logging system
随机推荐
Base64 编码原来还可以这么理解
jmeter脚本参数化
CodeCraft-22 and Codeforces Round #795 (Div. 2)D,E
4. Array pointer and pointer array
Makefile separates file names and suffixes
C# 线程传参
mathML转latex
taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,淘宝R2接口,淘宝oAuth2.0交易接口代码分享
C#延时、在线程中开启定时器、获取系统时间
info [email protected]: The platform “win32“ is incompatible with this module.
Full of knowledge points, how to use JMeter to generate encrypted data and write it to the database? Don't collect it quickly
Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
About text selection in web pages and counting the length of selected text
关于网页中的文本选择以及统计选中文本长度
[QNX hypervisor 2.2 user manual]6.3 communication between guest and external
fatal: unsafe repository is owned by someone else 的解决方法
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
大顶堆、小顶堆与堆排序
tmall.product.schema.get( 产品信息获取schema获取 ),淘宝店铺上传商品API接口,淘宝商品发布接口,淘宝商品上传API接口,店铺上传接口,oAuth2.0接口