0

I have a pretty simple foreach loop for an array (arrayA) in PHP. I am trying to filter another array (arrayB) by the current key of arrayA.

Here is my code:

foreach ($arrayA as $questionKey = $questionValue) {
  $data = array_filter($arrayB, function ($key) {
    return $questionKey == $key;
  }, ARRAY_FILTER_USE_KEY);
  print_r($data);
}

However, I am getting an Undefined Variable: questionKey error.

What am I missing?

user4889134
  • 111
  • 2
  • 16

0 Answers0