Hi, I want to get the characters after the last / in an url like http://www.vimeo.com/1234567
How do I do with php?
Hi, I want to get the characters after the last / in an url like http://www.vimeo.com/1234567
How do I do with php?
You could explode() based on "/" and get the last entry.
print end(explode("/", "http://www.vimeo.com/1234567"));
Very simply:
$id = substr( $url, strrpos( $url, '/' )+1 );
strrpos
gets the position of the last occurrence of the slash; substr
returns everything after that position.
array_pop(explode("/", "http://vimeo.com/1234567"));
will return the last element of the example url
$str = "http://www.vimeo.com/1234567";
$s = explode("/",$str);
print end($s);