Last active
September 19, 2016 07:52
-
-
Save chrisyue/c2fcf285ee3185a0b2e2bd4009e6ab45 to your computer and use it in GitHub Desktop.
通过正则递归搜索指定目录里的文件
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 | |
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.', FilesystemIterator::SKIP_DOTS)), '/\.m3u8$/') as $file) { | |
$name = $file->getBasename(sprintf('.%s', $file->getExtension())); | |
$content = file_get_contents($file->getRealPath()); | |
$newContent = str_replace($name, urlencode($name), $content); | |
file_put_contents($file->getRealPath(), $newContent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment