Faster way to intersect arrays
I tried hard but I couldn't find anything faster than the native array_intersect_key. It runs 30-50% faster than your function in my tests. Tried with PHP 7.0 and this array generator for test data:
function randomArr($size, $max) {
  $res = [];
  for ($i = 0 ; $i&lt;$size; $i++) {
    $r = random_int(1, $max);
    if (!isset($res[$r])) {
      $res[$r] = true;
    }
    else {
      $i = $i-1;
    }
  }
  ksort($res);
  return $res;
} 

Try with 10 Mio entries and $max=100000000 and I'd be really surprised if your function was faster. Maybe the densitiy of your arrays plays a role?
However, I found one little optimization for your function: If you don't require the result to have the form [3 =&gt; true, 7 =&gt; true, 23 =&gt; true, ...], but you can work with [0 =&gt; 3, 1 =&gt; 7, 2 =&gt; 23, ...] as well, it's a bit faster to just push the intersection keys onto the result array: $intersection[] = $chave1;. But this only saved me at most 10%.