1

I'm making a simple FTP client in PHP, and I'd like to use an equivalent of is_dir.
Basically I have:

$ftp_connection = ftp_connect($ftp_server,$ftp_port,$timeout) or die("Could not connect to $ftp_server");
/* other things here */
$documents = ftp_rawlist($ftp_connection,ftp_pwd($ftp_connection));
foreach($documents as $current_document){
   /* if is_dir($current_document) do something */
      echo $current_document;
      echo "<br>";
}

Obviously it does not work, and I tried to resolve in this way:

if($current_document[0]=='d') /* do something */;

And it works fine, but I'm not sure it's a correct way, thus, I'd like to use ftp_nlist rather than ftp_rawlist.

AlessandroF
  • 542
  • 5
  • 16
  • If it is an open-source project I would like to contribute, I have already made a PHP FTP library https://github.com/lazzard/php-ftp-client, I would be happy to share my knowledge with other people. – Shakir El Amrani Aug 26 '20 at 20:01
  • @PainNagatu Thank you so much! I starred your repo on Github, my project is open source too (https://github.com/xfarrow/FTP_HTTPmiddleware) but I have to warn you that is kinda a personal project to acquire knowledge in PHP, maybe if you see my code you'll freak out xD I'll check your library and I'll be surely happy to study it and use it, thank you! – AlessandroF Aug 27 '20 at 07:09
  • 1
    Thank you! believe me, I was just like you, I was writing a plain poor code most of the time, but if you spend a lot of time to read and learn code of other people, you'll see improvements in every day, however, I've checked your project and I would be very happy to contribute, thanks! – Shakir El Amrani Aug 27 '20 at 08:54

0 Answers0