I have a multi-dimensional array in the following format:
[0] = (
'id' => '1',
'type' => 'fish',
'owner' => 'bob',
)
[1] = (
'id' => '2',
'type' => 'cat',
'owner' => 'mary',
)
[2] = (
'id' => '3',
'type' => 'dog',
'owner' => 'larry',
)
[3] = (
'id' => '2',
'type' => 'cat',
'owner' => 'fred',
)
I would like to search for a value, and they return an array that contains all keys from matching arrays and looks like this on a search for type=cat:
[0] = (
'id' => '2',
'type' => 'cat',
'owner' => 'mary',
)
[1] = (
'id' => '2',
'type' => 'cat',
'owner' => 'fred',
)
I know I’m trying to treat the array as a database, but in this case it’s dynamic data that doesn’t need to be stored once the program ends.
Any advice?
Loop through the array: