speet testing (was URL parsing)
| From: | Sean Burlington | Date: | Thu, 19 Dec 2002 09:25:09 +0000 |
| Subject: | speet testing (was URL parsing) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128818@lists.php.net to get a copy of this message | ||
1LT John W. Holmes wrote:
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 -- Sean