Q:

Get a part of a string

Possible Duplicate:
Extract part from URL for a query string
how do i parse url php 

I have a string like this one:
http://twitter.com/what/
How can I get the what part ?
Basically I want to get the last part of a URL

A:

http://php.net/manual/en/function.parse-url.php
$url = "http://twitter.com/what/";

$parts = parse_url($url);

$what = substr($parts['path'], 1, strlen($parts['path']) - 2);

A:

$url = "http://twitter.com/what/";
echo basename($url);

