开发者

Extract part of a string in php

i have this kind of string into my db

http://www.my开发者_Python百科domain.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 "/" ?


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


You can use the basename function.

basename('http://www.mydomain.com/assets/Image/......./image.jpg');


 echo preg_replace('~.+/~', '', $url);

see also parse_url, pathinfo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜