Jump to content

Chop off file paths


roxii

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.