Re: Show Filename using Wildcards
| From: | Brad Bonkoski | Date: | Thu, 29 Mar 2007 19:22:02 +0000 |
| Subject: | Re: Show Filename using Wildcards | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-251661@lists.php.net to get a copy of this message | ||
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@rahulsjohari.com ³I morti non sono piu soli ... The dead are no longer lonely²