note 96339 modified in function.preg-match by thiago

From: Date: Mon, 22 Feb 2010 02:10:05 +0000
Subject: note 96339 modified in function.preg-match by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-166229@lists.php.net to get a copy of this message
To extract scheme, host, path, ect. simply use <?php $url = 'http://name:pass@'; $url .= 'example.com:10000'; $url .= '/path/to/file.php?a=1&amp;b=2#anchor'; $url_data = parse_url ( $url ); print_r ( $url_data ); ?> ___ prints out something like: Array ( [scheme] => http [host] => wild.subdomain.orgy.domain.co.uk [port] => 10000 [user] => name [pass] => pass [path] => /path/to/file.php [query] => a=1&b=2 [fragment] => anchor ) In my tests parse_url is up to 15x faster than preg_match(_all)! --was-- To extract scheme, host, path, ect. simply use <?php $url = 'http://name:pass@'; $url .= 'wild.subdomain.orgy.domain.co.uk:10000'; $url .= '/path/to/file.php?a=1&amp;b=2#anchor'; $url_data = parse_url ( $url ); print_r ( $url_data ); ?> ___ prints out something like: Array ( [scheme] => http [host] => wild.subdomain.orgy.domain.co.uk [port] => 10000 [user] => name [pass] => pass [path] => /path/to/file.php [query] => a=1&b=2 [fragment] => anchor ) In my tests parse_url is up to 15x faster than preg_match(_all)! http://php.net/manual/en/function.preg-match.php

« previous php.notes (#166229) next »