How to delete directory custom functions in PHP

不言
Release: 2023-04-03 06:26:01
Original
2116 people have browsed it

This article mainly introduces how to delete directory custom functions in PHP. It has certain reference value. Now I share it with you. Friends in need can refer to it.

function rm_dir($dir)
{
    if($handle = opendir($dir))
    {
        while (false !== ($item = readdir($handle)))
        {
            if($item != "." && $item != "..")
            {
                if(is_dir("$dir/$item"))
                {
                    rm_dir("$dir/$item");
                }
                else
                {
                    unlink("$dir/$item");
                    echo "removing $dir/$item
";
                }
            }
        }
        closedir($handle);
        rmdir($dir);
        echo "removing$dir
";
    }
}
Copy after login

The above is the entire content of this article. , I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Introduction to PHP’s random probability calculation function

The above is the detailed content of How to delete directory custom functions in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template