Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How php checks the line in which the value is in the array

2025-01-19 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 check the value of php in the 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 check the value of php in the array" can help you solve the problem.

Check the number of rows: 1, use the "array_values ($arr)" statement to convert the specified array into an indexed array; 2, use the "array_search (" value ", indexed array)" statement to search the specified value in the indexed array and return the corresponding index; 3, use the "index value + 1" statement to calculate the number of rows of the specified value in the array.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

The line in which the php check value is in the array

Implementation method:

Use array_values () to get the values of all the elements in the array and return an array containing all the key values, which turns the array into an indexed array.

Use array_search () to search for the given value in the indexed array and return the corresponding index value

The array index value starts at 0, so the number of rows of the specified value needs to be added by 1 to the index value obtained.

Implementation example:

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report