In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of "how to find the maximum and minimum values of the php array". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to find the maximum and minimum values of the php array" can help you solve the problem.
There are two methods: 1. Use the "max" statement to get the maximum value and the "min" statement to get the minimum value. 2. Use "sort" to sort the array in ascending order, "array_key_first" to get the minimum value, and "array_key_last (array)" to get the maximum value.
Operating environment of this tutorial: windows7 system, PHP7.5 version, DELL G3 computer
In php, there are many ways to get the maximum and minimum values of an array. Here are two ways:
Method 1: use the max () and min () functions
The max () function returns the maximum value in an array
The min () function returns the minimum value in an array
Example:
Method 2: use the sort (), array_key_first (), array_key_last () functions
You can use sort () to sort the array in ascending order
At this point, you can see that the first element of the array is the minimum value, and the last element is the maximum value. You only need to take out these two values.
So how to get the first and last element of the array, you can use the array_key_first () and array_key_last () functions
Array_key_first () gets the first key value of the specified array.
Array_key_last () gets the last key value of the specified array.
The maximum value of the echo array is: ".array _ key_last ($arr)."
The maximum value of the "; echo" array is: ".array _ key_first ($arr)."
"
Note: PHP versions of these two functions: PHP 7 > = 7.3.0, PHP 8
This is the end of the content about "how to find the maximum and minimum values of the php array". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.