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 introduces the knowledge of "how to find the minimum value in an array". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Three methods: 1. Get it with "min ($arr)". 2. Sort in ascending order with "sort ($arr)". After sorting, the first element is the minimum value, which is obtained by "reset ($arr)". 3. Sort in descending order with "rsort ($arr)" and get the last element with "end ($arr)".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
The method of finding the minimum value of Array by php
In PHP, to get the minimum value of an array, you can directly use the built-in function min ()
You can also sort the array elements, getting the last element in descending order and the first element in ascending order.
Let's take a look at the details.
1. Use the min () function
The min () function returns the minimum value in an array
2. Sort in ascending order and get the first element
You can use sort () to sort the array in ascending order
After sorting, the first element of the array is the minimum value, which can be taken out using the reset () function.
The minimum value of the echo "array is:" .reset ($arr)
3. Sort in descending order and get the last element
Using rsort to sort the array in descending order
After sorting, the last element is the minimum value, which can be obtained using the end () function.
The minimum value of the echo "array is:" .end ($arr)
That's all for "how to find the minimum value in an array by php". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.