PHP在获取指定目录下的目录,在获取的目录下面再创建文件,多平台
PHP在获取指定目录下的目录,在获取的目录下面再创建文件,多平台,需要的朋友可以参考下。
代码如下:
//取得指定文件夹的目录名称
function get_dir_name($dir_path,$file)
{
$dirpath = $dir_path;
$dir = scandir($dirpath);
foreach ($dir as $key=>$value)
{
if (is_dir($dirpath.'/'.$value) && $value != '.' && $value != '..')
{
//echo $dirpath.'/'.$value.'/'.$file;
//在目录下生成一个config.php文件,当然这个文件可以自己定义了
if (!file_exists($dirpath.'/'.$value.'/'.$file))
{
$fo = fopen($dirpath.'/'.$value.'/'.$file,'xb+'); //在这里的时候,我之前尝试用w+,结果失败,
//在windows 下,我有创建成功,请注意了!所有建议用xb+,兼容多平台
chmod($file,"0777");
fwrite( $fo,'i is a zongzi ,here is config file!') or die('配置文件创建失败!请检查是否有此目录和文件的操作权限!');
fclose($fo);
}
$arr[] = $value;
}
}
return $arr;
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Whether it is an article, paper or tutorial, the main highlight of any document is the title and of course the table of contents. It describes the outline structure of the document so that users can get to where and what they expect to read from the document. It's also a best practice to add a table of contents to most documents to make them look more professional. Today, everything happens online and people use Google Docs to create most documents. Many users are still not sure how to insert or add a table of contents in google docs. Therefore, we come up with this article to explain how to create or insert a table of contents in Google Docs. How to Insert a Table of Contents in Google Docs Step 1: Click here to visit Google Docs Online. Step 2: If

Use Java's File.isDirectory() function to determine whether a file exists and is of directory type. In Java programming, you often encounter situations where you need to determine whether a file exists and is of directory type. Java provides the File class to operate files and directories. The isDirectory() function can help us determine whether a file is a directory type. The File.isDirectory() function is a method in the File class. Its function is to determine the current File

The glob() function in PHP is used to find files or directories and is a powerful file operation function. It can return the path of a file or directory based on a specified pattern match. The syntax of the glob() function is as follows: glob(pattern, flags) where pattern represents the pattern string to be matched, which can be a wildcard expression, such as *.txt (matching files ending with .txt), or a specific file path. flags is an optional parameter used to control the function

PHP function introduction—rename(): Renaming files or directories Introduction: In PHP, the rename() function is used to rename files or directories. It provides an easy way to change the name of a file or directory. Whether it is a single file or an entire directory, you can use this function to perform a rename operation. The renaming process can be easily accomplished by specifying the name of the source file or directory and the target name. Syntax: boolrename(string$source,str

How to check whether the directory is empty in Linux: 1. Enter the Linux terminal; 2. By executing "res=`ls -A $dir` if [ -z $res ]; then echo "$dir ..."else echo "$ The dir..."fi" method can determine whether the directory is empty.

Select the style of the catalog in Word, and it will be automatically generated after the operation is completed. Analysis 1. Go to Word on your computer and click to import. 2After entering, click on the file directory. 3 Then select the style of the directory. 4. After the operation is completed, you can see that the file directory is automatically generated. Supplement: The table of contents of the summary/notes article is automatically generated, including first-level headings, second-level headings and third-level headings, usually no more than third-level headings.

Use the path/filepath.Split function to split the path into two parts: directory and file name. When developing programs or processing files, it is often necessary to split the path into two parts: directory and file name. In Go language, you can use the Split function in the path/filepath package to achieve this function. This article will introduce the usage of the Split function and give code examples. The Split function is defined as follows: funcSplit(pathstring)(di

The mobile version of WeChat Reading App is a very good reading software. This software provides a lot of books. You can read them anytime, anywhere with just one click to search and read them online. All of them are officially authorized and different types of books are neatly arranged. Sort and enjoy a comfortable and relaxing reading atmosphere. Switch the reading modes of different scenarios, update the latest book chapters continuously every day, support online login from multiple devices, and batch download to the bookshelf. You can read it with or without the Internet, so that everyone can discover more knowledge from it. Now the editor details it online Promote the method of viewing the catalog for WeChat reading partners. 1. Open the book you want to view the catalog and click in the middle of the book. 2. Click the three lines icon in the lower left corner. 3. In the pop-up window, view the book catalog
