# glob to take array as an arg

- Thread: https://externals.io/message/18565
- Original archive: https://news-web.php.net/php.internals/18565
- Started by Kevin Waterson on 2005-08-30T13:54:53+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #18565 — Kevin Waterson — 2005-08-30T13:54:53+00:00

URL: https://externals.io/message/18565#18565

Currently glob takes a string such as
array glob ( string pattern [, int flags] )

I would like to make this

array glob ( array patterns [, int flags] )

This would tidy up much code where a series of OR's are used to match
different patterns.

$arr = array('jpg', 'gif', 'tif', 'pdf', 'bmp', 'raw');
foreach(glob($arr as $file)){ echo $file; }

This would be better handled interally and the sequential search should
be faster handled internally.

Kevin
-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #18566 — Kevin Waterson — 2005-08-30T13:59:34+00:00

URL: https://externals.io/message/18565#18566 · In reply to: #18565

This one time, at band camp, Kevin Waterson <kevin@oceania.net> wrote:

> array glob ( array patterns [, int flags] )

Should be 
array glob ( mixed pattern [, int flags] )

Kevin
-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #18585 — Peter Brodersen — 2005-08-30T22:09:27+00:00

URL: https://externals.io/message/18565#18585 · In reply to: #18565

On Tue, 30 Aug 2005 23:54:53 +1000, in php.internals kevin@oceania.net
(Kevin Waterson) wrote:

>I would like to make this
>
>array glob ( array patterns [, int flags] )
>
>This would tidy up much code where a series of OR's are used to match
>different patterns.
>
>$arr = array('jpg', 'gif', 'tif', 'pdf', 'bmp', 'raw');
>foreach(glob($arr as $file)){ echo $file; }

glob is currently extremely flexible in its input with the right flags
and can expand a list. Eg:

print_r(glob("*.{jpg,gif,tif,pdf,bmp,raw}",GLOB_BRACE));

If all you want is to supply `glob()` with a list of full or partial
patterns I think the desired functionality is already present.

-- 
- Peter Brodersen

---

## #18589 — Kevin Waterson — 2005-08-31T01:39:04+00:00

URL: https://externals.io/message/18565#18589 · In reply to: #18585

This one time, at band camp, Peter Brodersen <php@ter.dk> wrote:

> > […]
> 
> glob is currently extremely flexible in its input with the right flags
> and can expand a list. Eg:
> 
> print_r(glob("*.{jpg,gif,tif,pdf,bmp,raw}",GLOB_BRACE));

True, but not available to all. It is GNU.

Kevin
-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #18595 — Kevin Waterson — 2005-08-31T08:44:34+00:00

URL: https://externals.io/message/18565#18595 · In reply to: #18585

This one time, at band camp, Peter Brodersen <php@ter.dk> wrote:


> If all you want is to supply `glob()` with a list of full or partial
> patterns I think the desired functionality is already present.

But not on all platforms.

Kevin


-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

---

## #18635 — Peter Brodersen — 2005-09-01T03:15:08+00:00

URL: https://externals.io/message/18565#18635 · In reply to: #18589

On Wed, 31 Aug 2005 11:39:04 +1000, in php.internals kevin@oceania.net
(Kevin Waterson) wrote:

> > […]
>
>True, but not available to all. It is GNU.

You are right - I missed that win32 uses win32/glob.h

I think a better solution is just to create an emulation for
GLOB_BRACE. This is nothing new, `GLOB_ONLYDIR` is already emulated on
systems not using the GNU C library (where GLOB_EMULATE_ONLYDIR is
defined instead) since 4.3.3.

On one hand it would be nice with more cross-platform-compatibility.
Using local libraries might create incompatibility, forcing users to
make usage of PEAR libraries and such instead of native functions
(though File_Find, that has just reached stable for a 1.0.x-release,
could be an alternative).

On the other hand, more code would make require more maintenance. Not
that it seems like glob.h is that troublesome.

-- 
- Peter Brodersen
