Answers for "use external variable in php function"

PHP
0

use external variable in php function

//Make a new array $arr3 from $arr1 where keys of $arr1 is not in keys of $arr2
$arr = ['a' => 1, 'b' => 2, 'c' => 3];
$arr2 = ['a' => 5, 'b' => 6];

$arr3 = array_filter($arr, function ($k) use ($arr2) {
  return !in_array($k, array_keys($arr2));
}, ARRAY_FILTER_USE_KEY);
Posted by: Guest on March-01-2022

Code answers related to "use external variable in php function"

Browse Popular Code Answers by Language