Last active
August 27, 2018 04:12
-
-
Save alphp/7f31da1e5fc3f1d6d609a0ca57687299 to your computer and use it in GitHub Desktop.
Rename a path (PHP)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('path_check.php'); | |
function path_rename ($from, $to) { | |
if (is_dir($from)) { | |
path_check($to, 0777); | |
foreach (glob($from . DIRECTORY_SEPARATOR . '*') as $item) { | |
path_rename($item, $to . DIRECTORY_SEPARATOR . basename($item)); | |
} | |
rmdir($from); | |
} else { | |
rename($from, $to); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment