Home > Backend Development > PHP Tutorial > How to get the maximum subscript of an array in PHP_PHP Tutorial

How to get the maximum subscript of an array in PHP_PHP Tutorial

WBOY
Release: 2016-07-13 09:53:38
Original
1503 people have browsed it

How to get the maximum subscript of an array in PHP

This article mainly introduces the method of getting the maximum subscript of an array in PHP, involving the operation of arrays by functions such as max and array_search in PHP Tips, friends in need can refer to it

The example in this article describes the method of obtaining the maximum subscript of an array in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

 ?

1

2

3

4

5

$hots = array('8213'=> 0,'8212'=> 100,'8172'=> 10008);

$key = array_search(max($hots),$hots);

echo $key;

?>

1

2

3 4

5
$hots = array('8213'=> 0,'8212'=> 100,'8172'=> 10008); $key = array_search(max($hots),$hots); echo $key; ?>
The running result is: 8172
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/1000118.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1000118.htmlTechArticleHow to get the maximum subscript of an array in PHP This article mainly introduces the method of getting the maximum subscript of an array in PHP, involving Relevant skills for operating arrays with functions such as max and array_search in php, required...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template