php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69384 Add glob_filter() function
Submitted: 2015-04-06 13:38 UTC Modified: -
From: bschussek at gmail dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.6.8RC1 OS: Ubuntu 14.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bschussek at gmail dot com
New email:
PHP Version: OS:

 

 [2015-04-06 13:38 UTC] bschussek at gmail dot com
Description:
------------
I'd love to see a glob_filter() function that filters an array of file paths for those file paths matching a glob, with the same rules used by glob(). This function is needed when a virtual file system (implemented in PHP) should be globbed for files.

Signature:

glob_filter(array $paths, string $glob[, int $flags = 0])

$paths - an array of file system paths
$glob - a glob
$flags - the glob() flags

Result: an array of matching file system paths

Test script:
---------------
$input = array(
    '/css',
    '/css/reset.css',
    '/css/style.css',
    '/js',
    '/js/script.js',
);

foreach (glob_filter($input, '/*/*.css') as $path) {
    echo $path."\n";
}

Expected result:
----------------
/css/reset.css
/css/style.css


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jan 17 15:01:24 2020 UTC