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 Quote 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 ); ?> Quote 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)); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.