span style="color: #0000BB"><?phpfunction my_copy($var1, $var2) { if (is_file($var2)) { $shablon = preg_replace("/^(.+)(\.[^\.]+)$/", '$1(*)$2', $var2); $g = glob($shablon); $c = ((is_array($g))? count($g): 0); $var2 = str_replace('(*)', '(' . (($c)? ($c+1): 1) . ')', $shablon); } copy($var1,$var2); }my_copy('test.txt', './dir/test.txt');my_copy('test.txt', './dir/test.txt');my_copy('test.txt', './dir/test.txt');my_copy('test.txt', './dir/test.txt');my_copy('test.txt', 'test.txt');my_copy('test.txt', 'test.txt');my_copy('test.txt', 'test.txt');my_copy('test.txt', 'test.txt');my_copy('test.txt', 'test.txt');my_copy('test.txt', 'test.txt'); |