Re: SQL Distinct-like behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$files = glob("directory/*.jpg");
    will give you a list of all the jpg files in the directory,

$files_unique = array_unique($files);
    will get rid of the duplicates and create a shiny new array.


Regards,
Hamza.


PS: glob is case-sensitive so the above will only match *.jpg, and not *.JPG


""Marcelo de Moraes Serpa"" <celoserpa@xxxxxxxxx> wrote in message 
news:1e5bcefd0708231954q2784caeagaf22ba0ee860984b@xxxxxxxxxxxxxxxxx
> How could I iterate over the files in a directory and build a list of 
> unique
> filenames? Take the following filelist:
>
> file1_01.jpg
> file2_01.jpg
> file2_02.jpg
> file2_03.jpg
> file3_01.jpg
> file3_02.jpg
> file3_03.jpg
> file4_01.jpg
> file4_02.jpg
> file4_03.jpg
>
> I would like to build an array like this: $names =
> ("file1","file2","file3","file4")
>
> How could I do that ?
>
> Thanks in advance.
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux