Example 1 — Removing Entries by Key
Keep only the entries whose keys are not present in the second array.
<?php
$a = ['a' => 1, 'b' => 2, 'c' => 3];
$b = ['a' => 99, 'c' => 100];
print_r(array_diff_key($a, $b)); How It Works
- The keys 'a' and 'c' exist in both arrays, so those entries are removed.
- The values 99 and 100 in $b are ignored.
- The key 'b' exists only in $a, so it is kept.
- The result is ['b' => 2].

