roxii Posted May 19, 2006 Share Posted May 19, 2006 Gah, I never know what to use when I get into this type of situation. I'm using ftp_nlist to gather the files in a directory, but I need to get rid of the path in front of the files.[code]<?php$contents = ftp_nlist($conn, "/public_html/assets/files");print_r($contents);?>[/code]That will print out:Array([0] => /public_html/assets/files/1.jpg[1] => /public_html/assets/files/2.jpg)All I want is the 1.jpg, 2.jpg, etc.What would be an appropriate function to use to chop off the last slash and everything before it?[b]EDITED BY WILTEEN88: PLEASE USE [ CODE][/CODE] (without the space) TAGS RATHER THAN [code=php:0][/code] TAGS AS PHPTAGS NO LONGER EXIST. THANK YOU.[/b] Quote Link to comment https://forums.phpfreaks.com/topic/9993-chop-off-file-paths/ Share on other sites More sharing options...
litebearer Posted May 19, 2006 Share Posted May 19, 2006 The answer is right on phpfreaks[a href=\"http://www.phpfreaks.com/phpmanual/page/function.strrchr.html\" target=\"_blank\"]http://www.phpfreaks.com/phpmanual/page/fu...on.strrchr.html[/a]Lite... Quote Link to comment https://forums.phpfreaks.com/topic/9993-chop-off-file-paths/#findComment-37131 Share on other sites More sharing options...
roxii Posted May 19, 2006 Author Share Posted May 19, 2006 That's what I'm looking for. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/9993-chop-off-file-paths/#findComment-37132 Share on other sites More sharing options...
yonta Posted May 19, 2006 Share Posted May 19, 2006 You could also use the [a href=\"http://pt.php.net/basename\" target=\"_blank\"]basename [/a]function. Quote Link to comment https://forums.phpfreaks.com/topic/9993-chop-off-file-paths/#findComment-37138 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.