Re: Regex in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 4, 2008 at 10:26 AM, Robert Cummings <robert@xxxxxxxxxxxxx>
wrote:

> Nope, case insensitive is slower since you must make two tests for
> characters having a lower and upper case version. With case sensitive
> comparisons you only need to make a single comparison.


a quick test shows stripos beating strpos.

<?php

$str = 'asSAFAASFDADSfasfjhalskfjhlaseAERQWERQWER;.dafasjhflasfjd';
$search = 'fdasASDFAafdas';

$start = microtime();
strpos($str, $search);
$end = microtime();
$r1 = $end - $start;

$start = microtime();
stripos($str, $search);
$end2 = microtime();
$r2 = $end2 - $start;

echo "strpos: $r1\n";
echo "stripos: $r2\n";

if($r2 < $r1) {
    echo 'stripos is faster' . PHP_EOL;
}
?>

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux