Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] glob + eregi
Forum PHP.pl > Forum > Przedszkole
kkuubbaa88
witam

istnieje jakis sposob, aby pobrac nazwy plikow za pomoca funkcji glob, filtrujac nazwy za pomoca eregi ? potrzebuje pobrac nazwy, ktore nie maja w sobie przykladowo slowa: 'foto';
nospor
http://pl.php.net/manual/en/function.glob.php
Cytat
glob's regex does not offer any kind of quantification of a specified character or character class or alternation. For instance, if you have the following files:

a.php
aa.php
aaa.php
ab.php
abc.php
b.php
bc.php

with pcre regex you can do ~^a+\.php$~ to return

a.php
aa.php
aaa.php

This is not possible with glob. If you are trying to do something like this, you can first narrow it down with glob, and then get exact matches with a full flavored regex engine. For example, if you wanted all of the php files in the previous list that only have one or more 'a' in it, you can do this:

<?php
$list = glob("a*.php");
foreach ($list as $l) {
if (preg_match("~^a+\.php$~",$file))
$files[] = $l;
}
?>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.