I want to get the characters after the last / in an url like
How do I do with php?
$id = substr($url, strrpos($url, '/') + 1);
As mentioned by redanimalwar if there is no slash this doesn't work correctly since
strrpos returns false. Here's a more robust version:
$pos = strrpos($url, '/'); $id = $pos === false ? $url : substr($url, $pos + 1);
$str = basename($url);