read file with astericks in the name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ellickjohnson
Forum Newbie
Posts: 2
Joined: Fri Oct 11, 2002 3:43 pm

read file with astericks in the name

Post by ellickjohnson »

I and trying to read a file file file(). The filename I am using needs to have astericks "*" in the name. PHP says " File not found if I use the *'s but if I put the full file name in it works fine. Any suggestions? I have tried escaping the *'s but no luck there.

Thasnk,
Ellick
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you want to open a file that has a * within the filename or want to use * to match an incomplete filename?
User avatar
EvilWalrus
Site Admin
Posts: 209
Joined: Thu Apr 18, 2002 3:21 pm
Location: Springmont, PA USA

Post by EvilWalrus »

an asterisk isn't a valid filename char is it?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try this in bash

Code: Select all

echo "test" > file\*test
it works
ellickjohnson
Forum Newbie
Posts: 2
Joined: Fri Oct 11, 2002 3:43 pm

Post by ellickjohnson »

I want to open a file using an asterik i.e. the file i want to open is 123stuffthatchanges789.txt

i'm trying to use file("123*789.txt");

is this possible?

Thanks
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

You would probably want to use readdir(), preg_match() and then your fopen() etc functions.

Read dir will get the file list, preg match will pick out the file, and then you can go from there.
Post Reply