Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.