find the filename from a string with php

后端 未结 3 744
面向向阳花
面向向阳花 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";
    

提交回复
热议问题