note 38373 added to function.copy

From: Date: Thu, 18 Dec 2003 13:32:42 +0000
Subject: note 38373 added to function.copy
Groups: php.notes 
Request: Send a blank email to php-notes+get-62175@lists.php.net to get a copy of this message
A better version for the example of torrmal at yahoo dot com published at 04-Jul-2003 11:05 function cp($wf, $wto) { $wf = rtrim ( $wf , "/"); $wto = rtrim ( $wto , "/"); mkdir($wto,0777); $arr=ls_a($wf); foreach ($arr as $fn) { if($fn) { $fl = $wf . "/" .$fn; if (strcmp ($fl, $wto) != 0) { $flto = $wto . "/" . $fn; if(is_dir($fl)) cp($fl,$flto); else copy($fl,$flto); } } } } function ls_a($wh) { if ($handle = opendir($wh)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." ) { if(!isset($files)) $files="$file"; else $files="$file\n$files"; } } closedir($handle); } $arr=explode("\n",$files); return $arr; } ---- Manual Page -- http://www.php.net/manual/en/function.copy.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38373 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38373&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38373&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#62175) next »