Re: String Parse Help for novice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

<?php

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 );

?>

Cheers,
Rob.

Rob:

Very neat.

It also handles url's like this:

<http://mydomain.com/mydirectory/mysubdirectory/anothersubdirectory/mypage.php>

See Demo here:

http://www.webbytedd.com/b4/parse-url/index.php

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux