Start · Sprachen · PHP · Referenz · glob

glob

Funktion

Findet Pfade, die auf ein Shell-Pattern passen — mit Wildcards <code>*</code>, <code>?</code>, <code>[abc]</code>.

seit PHP 4.3.0 Kategorie: io

Signatur

glob(string $pattern, int $flags = 0): array|false

Beschreibung

Kein Regex, sondern Shell-Globbing. Mit GLOB_BRACE: Klammer-Alternativen {jpg,png,gif}.

Parameter

Name Typ Default Beschreibung
$pattern Pflicht string Glob-Pattern.
$flags int 0 GLOB_BRACE, GLOB_ONLYDIR, GLOB_NOSORT, ...

Rückgabewert

Typ
array|false
Beschreibung
Gefundene Pfade.

Beispiele

Alle Bilder

<?php

$imgs = glob('*.{jpg,png,gif}', GLOB_BRACE);