tags:

views:

45

answers:

3

Hi, i have this kind of string into my db

http://www.mydomain.com/assets/Image/......./image.jpg

and would like to clean it up and make it

image.jpg

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

+8  A: 
$url = "http://www.mydomain.com/assets/Image/......./image.jpg";
$filename = basename($url);
echo $filename;
Srinivas Reddy Thatiparthy
hehe, so easy!!! thanks a lot my friend.
Sotos
+1  A: 

You can use the basename function.

basename('http://www.mydomain.com/assets/Image/......./image.jpg');
Cags
A: 
 echo preg_replace('~.+/~', '', $url);

see also parse_url, pathinfo

stereofrog
nice work around. thanks too
Sotos