How to get array key from corresponding array value?

前端 未结 5 900
-上瘾入骨i
-上瘾入骨i 2020-12-01 16:12

You can easily get an array value by its key like so: $value = array[$key] but what if I have the value and I want its key. What\'s the best way to get it?

5条回答
  •  天命终不由人
    2020-12-01 16:33

    Your array values can be duplicates so it wont give you exact keys. However the way i think is fine is like iterate over and read the keys

提交回复
热议问题