- microtime: documentation ( source)
- number_format: documentation ( source)
<?php
$n = 1000000;
// Create test array
$i = 0;
$array = array();
while($i < $n) {
$array[$i++] = true;
}
$time_start = microtime(true);
$i = 0;
while ($i < $n) {
$devnull = array_key_exists($i++, $array);
}
$time_end = microtime(true);
$time_while1= $time_end-$time_start;
echo number_format($time_while1, 3, '.', '')
." seconds - array_key_exists(array,i) on full array \n";