'jesuisTRToidaiosjj..d=09qwidek-320ik asdas a a d sad aas ds asd.jpg', 2 => 'filehuit.jpg', 3 => ' .dasd asdasdjask.jpgdkalsjd askldj aslkjd ajksdjaskld jaslk djaskl' ); for ( $i=1; $i<=3; $i++ ) { echo NL. 'Serie '.$i . NL; $str = $tab[$i]; test1($str); echo NL; test2($str); echo NL; test3($str); echo NL; test4($str); echo NL; test5($str); echo NL; test6($str); echo NL; test7($str); echo NL; } function test1($str) { echo 't1: '; $start=microtime(); for ($i=0; $i<5000; $i++) { if ( preg_match("/.+\.jpg$/i", $str) !== FALSE ) {} } $end = microtime(); echoTime($start,$end); } function test2($str) { echo 't2: '; $start=microtime(); for ($i=0; $i<5000; $i++) { if ( preg_match("/.\.jpg$/i", $str) !== FALSE) {} } $end=microtime(); echoTime($start,$end); } function test3($str) { echo 't3: '; $start=microtime(); for ($i=0; $i<5000; $i++) { if ( strtolower(substr ($str, strlen($str) - 4, 4)) == '.jpg' ) { } } $end=microtime(); echoTime($start,$end); } function test4($str) { echo 't4: '; # bugge.. retourne faux test.jpg.jpg $start=microtime(); for ($i=0; $i<5000; $i++) { if ( (strstr(strtolower($str),'.jpg')) == '.jpg' ) { } } $end=microtime(); echoTime($start,$end); } function test5($str) { echo 't5: '; /* $start=microtime(); for ($i=0; $i<5000; $i++) { if (eregi ('^.jpg$', substr ($str, strlen($str) - 4, 4))) {} } $end=microtime(); */ echoTime($start,$end); } function test6($str) { echo 't6: '; $start=microtime(); for ($i=0; $i<5000; $i++) { if (strrpos(strtolower($str),'.jpg') === (strlen($str)-4) ) { } } $end=microtime(); echoTime($start,$end); } function test7($str) { echo 't7: '; $start=microtime(); for ($i=0; $i<5000; $i++) { $long = strlen($str); if ($long>4) if ($str{($long-4)} == '.') if (strtolower($str{($long-3)}) == 'j') if (strtolower($str{($long-2)}) == 'p') if (strtolower($str{($long-1)}) == 'g') { } } $end=microtime(); echoTime($start,$end); } function echoTime($start, $end) { $s = explode(' ', $start); $e = explode(' ', $end); echo (($e[0]+$e[1])-($s[0]+$s[1])); } ?>