I’m trying to search for a substring within part of the bottom layer of a 2-layer array and return the key from the top layer. E.g. in the array below searching within “A” for “ca” would return “0” and “2” (but would miss “cattle”):
Array (
[0] => Array (
[A] => cat
[B] => horses
)
[1] => Array (
[A] => dog
[B] => cattle
)
[2] => Array (
[A] => cat
[B] => sheep
)
)
You can try like this :
Will output :
Note that this method is not encoding safe (you may use mb_str* instead of str* function family, more details here).