|
Posted by bill on 01/28/07 20:28
Rik wrote:
> bill <nobody@spamcop.net> wrote:
>
>> Rik wrote:
>>> bill <nobody@spamcop.net> wrote:
>>>
>>>> I need to parse a set of directory entries (of photo image files)
>>>> and pull out the names of the subjects, which is in the filename.
>>>>
>>>> A file name could contain 1 or more subject names from a limited set
>>>> of 18 possibilities.
>>>>
>>>> eg: the possibilities might be: Aoife, Alana, Liam, Paddy.....
>>>>
>>>> the file name might be: 0709-Aoife-Alana-DSC12435.jpg
>>>>
>>>> I could do 18 stripos() calls to check for all 18 possibilities, but
>>>> I thought I would run it by the more experienced to see if you can
>>>> suggest an easier way
>>>>
>>>> thanks in advance.
>>> $possibities = array('foo','bar','baz'........);
>>> $filenameparts = explode('-',$filename);
>>> $matches = array_intersect($filenameparts,$possibities);
>
> Addendum, if you want a case-insensitive comparison (PHP >= 5):
> $matches = array_uintersect($filenameparts,$possibities,'strcasecmp');
>
> --Rik Wasmus
thanks for the update, but my web host is still at 4.1.x
bill
Navigation:
[Reply to this message]
|