I know i can do it like this when i'm looking for value inside array.
$example = array('example','One more example','last example');
$searchword = 'last';
$matches = array_filter($example, function($var) use ($searchword) { return preg_match("/\b$searchword\b/i", $var); });
However I'm wanting to do something like this but for this example:
$example = array( "first" => "bar", "second" => "foo", "last example" => "boo");
$searchword = 'last';
How can I change this to get the key value which contains searchword
instead of the value?
$matches = array_filter($example, function($var) use ($searchword) { return preg_match("/\b$searchword\b/i", $var); });