例子:
图片网址:
localhost/example/folder/filename.jpg
我想获取图像的路径,所以它必须是:
localhost/example/folder/
怎么做?
我英语说得不好。谢谢!
我找到了一个解决方案,而不是使用 dirname:
$image = 'localhost/example/folder/filename.jpg';
$directory = substr($image, 0, strrpos($image, '/', -2) + 1 );
echo $directory;
//return: localhost/example/folder/