废话不多说,直接贴上代码。本文体现的就是简洁
复制代码 代码如下:
//删除目录下所有空目录
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