ZipArchive::addPattern

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL zip >= 1.9.0)

ZipArchive::addPatternAdd files from a directory by PCRE pattern

Beschreibung

public ZipArchive::addPattern(string $pattern, string $path = ".", array $options = []): array|false

Add files from a directory which match the regular expression pattern. The operation is not recursive. The pattern will be matched against the file name only.

Parameter-Liste

pattern

A PCRE pattern against which files will be matched.

path

The directory that will be scanned. Defaults to the current working directory.

options

An associative array of options accepted by ZipArchive::addGlob().

Rückgabewerte

An array of added files on success Bei einem Fehler wird false zurückgegeben.

Beispiele

Beispiel #1 ZipArchive::addPattern() example

Add all php scripts and text files from current directory

<?php
$zip 
= new ZipArchive();
$ret $zip->open('application.zip'ZipArchive::CREATE ZipArchive::OVERWRITE);
if (
$ret !== TRUE) {
    
printf('Failed with code %d'$ret);
} else {
    
$directory realpath('.');
    
$options = array('add_path' => 'sources/''remove_path' => $directory);
    
$zip->addPattern('/\.(?:php|txt)$/'$directory$options);
    
$zip->close();
}
?>

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

MMOEXP: Path of Exile 2's 0.5 update is a bold, messy, and exciting

The Path of Exile 2 Orbs (https://www.mmoexp.com/Poe-2/Currency.html?fsid=961106)​ community is buzzing with excitement and controversy followin ...

Geschrieben von Ludwighench am 09.06.2026 10:50:53
Forum: Ankündigungen
MMOexp Path of Exile 2: Massive Currency Farm with this Abyss Strategy

Struggling to Earn Divine Orbs? This Low-Investment Abyss Strategy Could Be the Answer Making currency in Path of Exile 2's endgame often feels l ...

Geschrieben von Lilidala am 09.06.2026 10:47:34
Forum: Fragen/Vorschläge zum Forum
MMOEXP: FC 26 is making headlines with its largest free content

FC 26 Coins (https://www.mmoexp.com/Fc-26/Coins.html?fsid=254377)​ is making headlines with its largest free content drop since launch: "The Wor ...

Geschrieben von Ludwighench am 09.06.2026 10:44:27
Forum: Ankündigungen
Pips Puzzle Adventure: A Fun Challenge for Every Player

Introduction to Pips Pips is an engaging puzzle game that combines logic, strategy, and creativity in a simple yet highly addictive format. The ...

Geschrieben von JesusaikNadeau am 09.06.2026 10:26:16
Forum: PHP Developer Forum