Search
 
SCRIPT & CODE EXAMPLE
 

PHP

copy folder contect to anthor folder php

public function recurseCopy($src,$dst, $childFolder='') { 

    $dir = opendir($src); 
    mkdir($dst);
    if ($childFolder!='') {
        mkdir($dst.'/'.$childFolder);

        while(false !== ( $file = readdir($dir)) ) { 
            if (( $file != '.' ) && ( $file != '..' )) { 
                if ( is_dir($src . '/' . $file) ) { 
                    $this->recurseCopy($src . '/' . $file,$dst.'/'.$childFolder . '/' . $file); 
                } 
                else { 
                    copy($src . '/' . $file, $dst.'/'.$childFolder . '/' . $file); 
                }  
            } 
        }
    }else{
            // return $cc; 
        while(false !== ( $file = readdir($dir)) ) { 
            if (( $file != '.' ) && ( $file != '..' )) { 
                if ( is_dir($src . '/' . $file) ) { 
                    $this->recurseCopy($src . '/' . $file,$dst . '/' . $file); 
                } 
                else { 
                    copy($src . '/' . $file, $dst . '/' . $file); 
                }  
            } 
        } 
    }
    
    closedir($dir); 
}
Comment

copy all folders from one directory to another php

function xcopy($src, $dest) {
    foreach (scandir($src) as $file) {
        if (!is_readable($src . '/' . $file)) continue;
        if (is_dir($src .'/' . $file) && ($file != '.') && ($file != '..') ) {
            mkdir($dest . '/' . $file);
            xcopy($src . '/' . $file, $dest . '/' . $file);
        } else {
            copy($src . '/' . $file, $dest . '/' . $file);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: location php ini mac os 
Php :: laravel db table get one columns value 
Php :: php read from mariadb 
Php :: autoload file laravel 
Php :: group where conditions in laravel 
Php :: php get bool from string 
Php :: How To Unset Or Delete An Element From Array By Value In PHP? 
Php :: generate unique order id in php 
Php :: PHP strtoupper — Make a string uppercase 
Php :: carbon between hours 
Php :: woocommerce_order_status_changed add action 
Php :: remove colon and white space in a string by php 
Php :: php foreach array pop 
Php :: check the route type in laravel 
Php :: wc create new category 
Php :: compact example in php 
Php :: php artisan insert user with tinker 
Php :: one lin if statement php 
Php :: php split string 
Php :: add top menu bar in wordpress 
Php :: faker image laravel 8 
Php :: get query string in symfony twig 
Php :: pmxi_gallery_image 
Php :: rest api response 404 wordpress 
Php :: symfony messenger conf 
Php :: get date to current week last or first day dates 
Php :: get users other than specific role laravel role spatie 
Php :: filter wordpress 
Php :: How to display custom field in wordpress? 
Php :: call api with php 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =