<?php
$m = range(1,1000000); // from one to a million
// Use array_intersect to return all $m values that are also in $s
echo "+--------------------------------------------------+\n";
//print_r (array_intersect($m,$s));
(double)$time = $tend - $tstart;
echo "| array_intersect took $time \n";
// Use array_flip and isset to return all $m values that are also in $s
// $u will hold the intersected values
$u = [];
foreach ($m as $v) {
if (isset($f[$v])) $u[] = $v; }
//print_r ($u);
(double)$time = $tend - $tstart;
echo "|\n";
echo "| array_flip took $time \n";
echo "+--------------------------------------------------+";
PD9waHAKCiAgJG0gPSByYW5nZSgxLDEwMDAwMDApOyAvLyBmcm9tIG9uZSB0byBhIG1pbGxpb24KICAkcyA9IHJhbmdlKDEsMTAwMDAwMCk7CgovLyBVc2UgYXJyYXlfaW50ZXJzZWN0IHRvIHJldHVybiBhbGwgJG0gdmFsdWVzIHRoYXQgYXJlIGFsc28gaW4gJHMKICAkdHN0YXJ0ID0gbWljcm90aW1lKHRydWUpOwogIGVjaG8gIistLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLStcbiI7CiAgLy9wcmludF9yIChhcnJheV9pbnRlcnNlY3QoJG0sJHMpKTsKICAkdGVuZCA9IG1pY3JvdGltZSh0cnVlKTsKICAoZG91YmxlKSR0aW1lID0gJHRlbmQgLSAkdHN0YXJ0OwoKICBlY2hvICJ8ICAgYXJyYXlfaW50ZXJzZWN0IHRvb2sgJHRpbWUgXG4iOwogIAovLyBVc2UgYXJyYXlfZmxpcCBhbmQgaXNzZXQgdG8gcmV0dXJuIGFsbCAkbSB2YWx1ZXMgdGhhdCBhcmUgYWxzbyBpbiAkcwogICR0c3RhcnQgPSBtaWNyb3RpbWUodHJ1ZSk7CiAgJGYgPSBhcnJheV9mbGlwKCRzKTsKLy8gJHUgd2lsbCBob2xkIHRoZSBpbnRlcnNlY3RlZCB2YWx1ZXMKICAkdSA9IFtdOwogIGZvcmVhY2ggKCRtIGFzICR2KSB7CiAgICBpZiAoaXNzZXQoJGZbJ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