note 97755 deleted from function.ftp-mkdir by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 May 2010 15:26:42 +0000 |
| Subject: | note 97755 deleted from function.ftp-mkdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-169013@lists.php.net to get a copy of this message | ||
Note Submitter: crashrox at gmail dot com
----
Cleaner recursive ftp mkdir
<?php
public static function mkdir($conn, $path) {
if(ftp_chdir($conn, $path)) {
return true; // path already exists, we're done
}
$directories = explode("/", $path);
$path = '';
foreach($directories as $dir) {
$path .= '/' . $dir;
if(!ftp_chdir($conn, $path)) {
if(!ftp_mkdir($conn, $path)) {
return false; // failed to create the directory
}
}
}
return true;
}
?>