search
Homephp教程php手册使用array_map简单搞定PHP删除文件、删除目录

这篇文章主要介绍了使用array_map简单搞定PHP删除文件、删除目录的相关资料,需要的朋友可以参考下

废话不多说,直接贴上代码。本文体现的就是简洁

复制代码 代码如下:


 
//删除目录下所有空目录
array_map('rmdir', glob('*', GLOB_ONLYDIR));
 
//删除目录所有文件
array_map('unlink', array_filter(glob('*'), 'is_file'));

使用array_map实现array_column功能:

复制代码 代码如下:


$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);

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)