function randword () { $word = ""; $size = rand (3, 20); for ($i = 0; $i < $size; $i++) { $randchr = chr (rand (ord ('a'), ord('z'))); $word .= $randchr; } return $word; } $total = 100000; $switch_start = microtime (TRUE); srand (0); $switch_end = microtime (TRUE); ' . $i . ",\n"; } echo ");\n"; ?> srand (0); $array_start = microtime (TRUE); for ($i = 0; $i < $total; $i++) { $randw = randword(); if (!array_key_exists ($randw, $asoc)) { $ret = -1; } else { $ret = $asoc[$randw]; } } $array_end = microtime (TRUE); echo "Total Iterations: $total\n"; echo "Switch Total Time: " . ($switch_end - $switch_start) . " ms\n"; echo "Array Total Time: " . ($array_end - $array_start) . " ms\n";