Move multiple .xml files to another PHP directory

2

Current Directory

Xmls / various files here ...

I want to pass all files from within Xmls to

Xmls / XmlsLidos

I tried to do with copy and then use unlink , but it did not work.

    
asked by anonymous 08.09.2016 / 20:35

1 answer

1

This is a process that can be done with the function, glob and rename :

<?php

    // pega a lista de arquivos com a extensão xml.
    $list = glob(__dir__.'/xml/*.xml');

    // diretorio aonde serão remanejados. 
    $save = __dir__.'/xmllido/';

    foreach ($list as $value) {
        if (rename($value, $save.basename($value))) {
            echo 'item enviado com exito';
        }
    }
    
08.09.2016 / 22:24