> > Assuming $url is what you have above:
> >
> > $tilde = strpos($url,"~");
> > $slash = strpos($url,"/",$tilde);
> > $length = $slash - $tilde;
> >
> > $username = substr($url,$tilde,$length);
> >
> > Or you can use a regular expression, but the above is probably faster.
> >
> > preg_match("!(~[^/]*)/!",$url,$match);
> > or
> > preg_match("!(~.*)/!U",$url,$match);
> >
> > In my tests, the first solution (using strpos) was the fastest by 35%.
> >
> > ---John Holmes...
> >
> >
>
> Hi John,
> Ive been very interested to note that you seem to have a very keen idea
> of the relative speed of different functions.
>
> I wonder if you could pass on some pointers for speed testing.
>
> thanks

Nothing fancy. Just using the getmicrotime() function defined on the
microtime() manual page to get the time before the bit I'm testing and after
and subtract to get the difference.

www.php.net/microtime

There are fancier classes out there that'll do this and create pretty graphs
and all that, too. I think PEAR has something to help with it.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to