I'm trying to find a way to check if the value of a given key exists in an array (inside a foreach loop).
For some reason it doesn't really work as expected.
The idea is that I already know the name of the key, but only know part of the correlating value for the key.
I'm trying to do something like this, assuming that I know the key is "exampleKeyName" and its value may or may-not contain "matchValue":
foreach( $array as $key => $value) {
if (stripos($array["exampleKeyName"], 'matchValue') !== false) { echo "matched"; }
}
This returns "illegal string offset".
However, if I do this it works:
foreach( $array as $key => $value) {
if (stripos($value, 'matchValue') !== false) { echo "matched"; }
}
The problem here is that I want to be more specific with the query, and only check if the key is "exampleKeyName".