tedd wrote:
At 9:29 PM -0400 6/13/10, Robert Cummings wrote:

function my_parse_url( $url )
    $parsed = parse_url( $url );
    $parsed['file'] = basename( $parsed['path'] );
$parsed['pathbits'] = explode( '/', ltrim( dirname( $parsed['path'] ), '/' ) );

    return $parsed;

$url = my_parse_url( 'http://foo.fee.com/blah/bleh/bluh/meh.php' );
print_r( $url );




Very neat.

It also handles url's like this:


See Demo here:


It's useful to leverage the work of others. So using parse_url() gets you all the parsing stuff for a url without having to worry about the spec (such as embedded user, password, port, parameters, and fragment. Then we just augment to provide the extra functionality :)

E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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

Reply via email to