Re: Extract Path from URL
| From: | Ignatius Reilly | Date: | Mon, 06 Jan 2003 15:00:50 +0000 |
| Subject: | Re: Extract Path from URL | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-17673@lists.php.net to get a copy of this message | ||
Don't use a regex:
Try:
$input = "http://www.test.com/path1/thisdoc.html"
;
// find last occurence of "/"
$pos = strrpos( $input, "/" ) ;
// extract until this position
$output = substr( $input, 0, $pos - strlen( $input ) + 1 ) ;
echo $output ;
HTH
Ignatius
____________________________________________
----- Original Message -----
From: "Herhuth, Ron" <Ron.Herhuth@tatumcfo.com>
To: <php-windows@lists.php.net>
Sent: Monday, January 06, 2003 3:51 PM
Subject: [PHP-WIN] Extract Path from URL
I'm having a tough time getting my head around regular expressions. Could
somebody show me how to extract the path (minus the file name) from this
URL:
http://www.test.com/path1/thisdoc.html
I would like to extract this:
http://www.test.com/path1/
Thanks in advance,
Ron
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php