jakebur01 Posted September 8, 2011 Share Posted September 8, 2011 Is there a way to trim everything off in front of the last backslash in the string? $trimFile = $fList[$i]; Example: In this path: \\\\myftp/downloads/tom/work/word_docs\\legal\test.pdf I only want to display test.pdf. Thanks, Jake Link to comment https://forums.phpfreaks.com/topic/246739-is-there-a-way-to-trim-everything-in-front-of-the-last-backslash/ Share on other sites More sharing options...
xyph Posted September 8, 2011 Share Posted September 8, 2011 <?php $str = '\\\\myftp/downloads/tom/work/word_docs\\legal\test.pdf'; $part = strrchr( $str, '\\' ); echo $part . '<br>'; echo substr( $part, 1 ); ?> Link to comment https://forums.phpfreaks.com/topic/246739-is-there-a-way-to-trim-everything-in-front-of-the-last-backslash/#findComment-1267100 Share on other sites More sharing options...
jakebur01 Posted September 8, 2011 Author Share Posted September 8, 2011 Thanks. I used this: $trimFile = end(explode('\\',$trimFile)); Link to comment https://forums.phpfreaks.com/topic/246739-is-there-a-way-to-trim-everything-in-front-of-the-last-backslash/#findComment-1267110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.