Hi guys,
I have a complete link to an image which is dynamic so declared as a variable...
eg url = 'http://somelink.com/images/image.jpg'
I want to remove the url part with the exception of the image name and extention. So I'm looking to do something like this....
change url from 'http://somelink.com/image.jpg' to just image.jpg.
I've tried using preg_replace...
This works...
This doesn't...PHP Code:$url = 'http://somelink.com/images/image.jpg';
preg_replace('/http:\/\/somelink.com\/images\//', '', $url);
I'm guessing I need to do something to $link to escape the slashes but I don't have a clue what to do! Can anyone help please?PHP Code:$link = 'http://somelink.com';
$url = 'http://somelink.com/images/image.jpg';
preg_replace('/'.$link.'\/images\//', '', $url);
Thanks in advance
Smithster


Reply With Quote

Bookmarks