- substr: documentation ( source)
- microtime: documentation ( source)
- str_shuffle: documentation ( source)
- round: documentation ( source)
<?php
function getRandomStr($length){
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
$start = microtime(true);
function put(&$mixed, $key, $value) {
if (is_array($mixed)) {
$mixed[$key] = $value;
} else {
// Do something else which we don't care about here
}
}
$mixed = array();
for($i = 0; $i < 10000; $i++) {
put($mixed, getRandomStr(15), 'abcd');
}
print round(microtime(true) - $start, 2) . 's';