find the filename from a string with php

后端 未结 3 723
面向向阳花
面向向阳花 2021-01-17 21:15
public/images/portfolio/i-vis/1.jpg

How could i remove all the path regardless of what the filename is using php?

3条回答
  •  梦毁少年i
    2021-01-17 21:54

    alternative solution. Just a bunch of explodes

    $str='public/images/portfolio/i-vis/1.jpg';
    $s = end(explode("/",$str));
    print "filename " . $s."\n";
    $e = explode(".", $s );
    print "without extension: $e[0]\n";
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题