Use array_map to simply delete files and directories in PHP, _PHP tutorial

WBOY
Release: 2016-07-13 10:15:44
Original
1042 people have browsed it

Use array_map to easily delete files and directories in PHP,

Without further ado, let’s just paste the code. This article embodies simplicity

Copy code The code is as follows:


//Delete all empty directories under the directory
array_map('rmdir', glob('*', GLOB_ONLYDIR));

//Delete all files in the directory
array_map('unlink', array_filter(glob('*'), 'is_file'));

Use array_map to implement array_column function:

Copy code The code is as follows:

$data = array(
array(
         'a' => 'first a',
'b' => 'first b'
),
array(
'a' => 'second a',
'b' => 'second b'
)
);

$array_column = array_map(function($element){
Return $element['a'];
}, $data);

print_r($array_column);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/902775.htmlTechArticleUse array_map to simply delete files and directories in PHP. Without further ado, just paste the code. This article embodies simplicity. Copy the code. The code is as follows: php //Delete all in the directory...
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