Re: Show Filename using Wildcards

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

 



Rahul Sitaram Johari wrote:
Ave,

I have a script where I have to provide a Download Link to a file associated
with a record. The common thing between the record & filename is the phone
number. But the filenames have dates & other symbols besides the phone
number as well. They all do begin with a phone number though.

How can I match a filename with a record using wildcards?
For example, let¹s say someone pulls up a record for phone field: 515515515
The files associated with this record could be 515515515031307 or
5155155150325T(2).
So you can see the filenames do begin the phone number in the record, but
they contain additional chars. What I need is something that can pull up all
515515515*.ext

Can I do this in PHP?
I'm sure there are many options...
I'm also assuming you are pulling from a file system and not a database...
So, loop through the directory and do something like this:
$phone_num = XXX
$cur_file = xxx
if( strncmp($phone_num, $cur_file, strlen($phone_num)) == 0 )
   //Matches
else
   //No Match

Ref: http://us3.php.net/manual/en/function.strncmp.php
(for case insensitive: http://us3.php.net/manual/en/function.strncasecmp.php)
-B
Thanks!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: sleepwalker@xxxxxxxxxxxxxxxx

³I morti non sono piu soli ... The dead are no longer lonely²



--
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