need the last part of the url
http://example.com then the last part is nothing if it is http://example.com/i then last part is i if it is http://example.com/i/am/fil
There is a function called parse_url().