<?php $a = []; $b = []; // populate $a for ($i = 0;$i < 10000; $i++) { $a[$i] = null; } // populate $b for ($i = 10000; $i < 20000; $i++) { $b[$i] = null; } // intersection somewhere in the middle $intersect = rand(5000, 6000); $b[$intersect] = null; $timer = microtime(); if (!empty(array_intersect_key($a, $b))) { var_dump('Method 1: INTERSECTION FOUND! Timer: ', microtime() - $timer); } $timer = microtime(); foreach ($a as $key => $val) { if (array_key_exists($key, $b)) { var_dump('Method 2: INTERSECTION FOUND! Timer: ', microtime() - $timer); break; } }
You have javascript disabled. You will not be able to edit any code.
Value for `_results` contains invalid data `array`