I have a multi-dimensional array similar to this:
$arr1 = array(
0 => array("departmentID"=>1,"userID"=>"3000001"),
1 => array("departmentID"=>2,"userID"=>"3000002"),
2 => array("departmentID"=>3,"userID"=>"3000003")
);
I basically need to search the array to see if a specific key/value pair exists. For example, I need to know if department ID 2 with userID 3000002 is in the array.
I've tried this code:
$key = array_search('2', array_column($arr1, 'departmentID'));
echo ("The key is: ".$key);
This works fine but it's only a search on the department ID. I need to know if the departmentID value of 2 exists with the userID value of 3000002 and I can't quite figure it out.
Would be grateful for any help!