phpurltext-extractionurl-parsingbasename

Get the basename substring from a URL string


I have this string in my db http://www.example.com/assets/Image/......./image.jpg

and would like to clean it up and make it

image.jpg

How could I get the part of the string starting from the right until the first "/"?


Solution

  • $url = "http://www.mydomain.com/assets/Image/......./image.jpg";
    $filename = basename($url);
    echo $filename;