- array_map: documentation ( source)
- microtime: documentation ( source)
- array_fill: documentation ( source)
- fclose: documentation ( source)
- fopen: documentation ( source)
<?php
$array = array_fill(0, 10, fopen('php://temp', 'r+'));
$t1 = microtime(true);
foreach ($array as $key) {
fclose($key);
}
echo microtime(true) - $t1 . PHP_EOL;
$t2 = microtime(true);
array_map('fclose', $array);
echo microtime(true) - $t2 . PHP_EOL;