当我为该目录中的所有img文件创建"gallery/png.png","gallery/jpg.jpg","gallery/gif.gif"等时,我为php库提供了一个名为$file_path;
的字符串。我想删除“图库/”和".format"的$file_path;
。
发布于 2018-02-18 13:21:28
试一试,希望它能成功。
$file_path = str_replace('gallery/', '', str_replace('.png', '', $file_path) );
发布于 2018-02-18 13:08:45
尝尝这个
str_replace('gallery/', '', $file_path);
发布于 2018-02-18 13:16:58
$url = "gallery/test.png";
$string = str_split($url);
$phase = 0;
$output;
for($i = 0; $i < count($string); $i++){
if($phase==1){if($string[$i]!="."){$output.=$string[$i];}else{break;}}else{if($string[$i]=="/"){$phase++;}}}
echo $output;
仅输出文件名
https://stackoverflow.com/questions/48856556
复制