I don’t know how to express it. In short, the requirement is somewhat similar to linq in C#.
Suppose there is the following array
<code>$test = [ 'a'=>'a1', 'b'=>'a1', 'c'=>'c1', ] </code>
I can now query 'a1' through $test['a'], but I also want to query the two elements 'a' and 'b' through 'a1'. How can I implement this in php? ?
Supplement: Some people say to use foreach to implement it, but my array may be very large in the later stage, even as large as thousands or tens of thousands. Using foreach is definitely not efficient.
The existing solutions can only solve the situation where the key value of each array element is different, that is, the one-to-one mapping situation. The first one is array_search, and the second one is array_flip first and then the traditional $test['a1'] search.