- microtime: documentation ( source)
- trim: documentation ( source)
- fgets: documentation ( source)
- fopen: documentation ( source)
<?php
$arr = array();
$fp = fopen("/usr/share/dict/words", "r");
while ($i < 5000 && ($w = fgets($fp))) {
$arr[trim($w)] = ++$i;
}
$s = microtime(1);
for ($i = 0; $i < 100000; $i++) {
isset($arr['abracadabra']);
}
$e = microtime(1);
echo "Isset: ".($e - $s)."\n";
$s = microtime(1);
for ($i = 0; $i < 100000; $i++) {
array_key_exists('abracadabra', $arr);
}
$e = microtime(1);
echo "array_key_exists: ".($e - $s)."\n";
?>