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 to find the key name by value in php Array

2025-04-01 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 key names through values in php arrays". In the operation of actual cases, many people will encounter such a dilemma, 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!

The php array can find the corresponding key name (key) by value. Two search methods: 1, with "array_search (value, array)", will return the corresponding key name; 2, with "foreach ($arr as $k = > $v) {if ($vault = value) {echo $k;}}", you can output the corresponding key name.

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

The php array can find the corresponding key name (key) by value.

The following article will introduce you to two search methods.

Method 1: use the array_search () function

The array_search () function searches the array for the specified key value and returns the corresponding key name.

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