so that http://foo.bar/dadadada.jpg
would return dadadada.jpg
and http://foo.bar/da-da.Da-da.jpg
would return da-da.Da-da.jpg
basically it needs to return the file name no matter what character is in the name, (hyphen, period, comma, underscore)
So far what I did was this, but it isn't working.
Code: Select all
$string = "http://foo.bar/dadadada.jpg";
$keyword = preg_split("#^\w+://\w+\.\w+/([-:a-z0-9]+).(\w+)#i", $string);
echo $keyword[0].".".$keyword[1];