Kurt111780
Technical User
Hello,
I need to trim a string and get the file name (everything after the last /)
file.txt
dir2/file.txt
dir3/dir4/file.txt
In all cases I need it to return file.txt with out any /.
I tried this but it still has the /.
then I tried this but it returns nothing if the / isn't there.
How can I do this? Thanks, Kurt
It's only easy when you know how.
I need to trim a string and get the file name (everything after the last /)
file.txt
dir2/file.txt
dir3/dir4/file.txt
In all cases I need it to return file.txt with out any /.
I tried this but it still has the /.
Code:
$trimName = strrchr($fileName, "/");
then I tried this but it returns nothing if the / isn't there.
Code:
$trimName = substr(($t=strrchr($fileName,'/'))!==false?$t:'',1);
How can I do this? Thanks, Kurt
It's only easy when you know how.