'PHP 7 - How to search for multiple specific members of an array

I have a PHP array that looks like this:

array (size=3)
  'CA,Santa Barbara' => 
    array (size=2)
      'state' => string 'CA' (length=2)
      'city' => string 'Santa Barbara' (length=13)
  'KS,Andover' => 
    array (size=2)
      'state' => string 'KS' (length=2)
      'city' => string 'Andover' (length=7)
  'KS,Wichita' => 
    array (size=2)
      'state' => string 'KS' (length=2)
      'city' => string 'Wichita' (length=7)

I need to return all the array members who have the values:

state => 'KS'

I am needing to get an array back that looks like this:

array (size=2)
  'KS,Andover' => 
    array (size=2)
      'state' => string 'KS' (length=2)
      'city' => string 'Andover' (length=7)
  'KS,Wichita' => 
    array (size=2)
      'state' => string 'KS' (length=2)
      'city' => string 'Wichita' (length=7)

Is there a PHP array function that does this? I have found array_search() but that only returns the first match. I need ALL matches.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source