ich rede doch nicht alles schlecht, deine idee mit dem like was zb astrein, auch wenns nicht besonders abgesichert war, aber wenn du zb 20 erweiterungen in dem array hast ist es langsamer als das preg_match beispiel
PHP-Code:
function microtime_float() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$ext = end(explode(".", strtolower('abcs.shtml')));
$s = microtime_float();
for ( $i = 0; $i < 2000; ++$i ) {
if( in_array( $ex, array('htm','html','shtm','shtml', 'txt', 'doc','zip','rar','rtf', 'php') ) )
continue;
}
echo '<br /><br />in_array: ' . (microtime_float()-$s);
$ext = strrchr ( 'abcs.shtml', '.' );
$s = microtime_float();
for ( $i = 0; $i < 2000; ++$i ) {
if( preg_match( '/s?html?|txt|doc|zip|rar|rtf|php/i' ,$ext ) )
continue;
}
echo '<br /><br />preg_match: ' . (microtime_float()-$s);
die masse machts