- Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Process exited with code 137.
<?php
error_reporting(0);
$results = array();
for($i = 0; $i < 100000; $i++) {
$results[] = (object) rand(0, 100000);
}
$start = microtime(true);
for($i = 0; $i < 1000; $i++) {
$alreadyOutput = array();
foreach ($results as $result) {
if(in_array($result->date, $alreadyOutput)){
continue;
}
$alreadyOutput[] = $result->date;
}
}
echo "in_array: ".(microtime(true) - $start)."ms || ";
$start2 = microtime(true);
for($i = 0; $i < 1000; $i++) {
$echoedArray = array();
foreach ($results as $result) {
if ($echoedArray[$result->date]) {
continue;
}
$echoedArray[$result->date] = true;
}
}
echo "by key: ".(microtime(true) - $start2)."ms";