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] 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... 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! 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. Link to comment https://forums.phpfreaks.com/topic/9993-chop-off-file-paths/#findComment-37138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.