Need to eliminate from Array A arrays that key 'service_code' value doesn't exist on Array B. In the example, only 'SAF' exists on Array B. Have tried a variety of array_intersect functions with no luck. Instead of doing a loop, I believe there must be a method unknown to me to accomplish this. I can also invert Array B by removing array_keys if necessary.
Array A
Array
(
[1] => Array
(
[id] => 2
[service_name] => Carpet Cleaning
[type] =>
[category_name] => Household
[service_code] => SAF
[category_code] => AA
)
[2] => Array
(
[id] => 3
[service_name] => Floor Cleaning
[type] =>
[category_name] => Household
[service_code] => MHSAF
[category_code] => AA
)
[3] => Array
(
[id] => 4
[service_name] => Lawn Service
[type] =>
[category_name] => Landscape
[service_code] => GHF
[category_code] => AA
)
)
Array B
Array
(
[0] => SAF
[1] => SA
[2] => MM
[3] => METH
[4] => OTPA
[5] => OTP
[6] => CBT
[7] => SACA
[8] => TRC
[9] => REBT
)
Expected Result
Array
(
[1] => Array
(
[id] => 2
[service_name] => Carpet Cleaning
[type] =>
[category_name] => Household
[service_code] => SAF
[category_code] => AA
)
)