我有字符串
'storage/product/home_decor/living_room/livingroom/7ce3da03b6854283bdd0b8e33b3e556a.11.09.2012.03.42.33.jpg'
如何通过 / 用 php 剪切最后一个字符串?
我希望我的输出是
'storage/product/home_decor/living_room/livingroom/'
我有字符串
'storage/product/home_decor/living_room/livingroom/7ce3da03b6854283bdd0b8e33b3e556a.11.09.2012.03.42.33.jpg'
如何通过 / 用 php 剪切最后一个字符串?
我希望我的输出是
'storage/product/home_decor/living_room/livingroom/'
如果您想保留最后一个 / 与您的结果,请使用以下代码:
$string = 'storage/product/home_decor/living_room/livingroom/7ce3da03b6854283bdd0b8e33b3e556a.11.09.2012.03.42.33.jpg';
$min = substr($string, 0, strrpos($string, '/') + 1);
echo $min; //output : storage/product/home_decor/living_room/livingroom/
substr($string, 0, strrpos($string, '/'));