简体   繁体   中英

How to delete (unlink) a file from directory, when its name starting with a dot (.) but its not a hidden file?

I'd like to delete (unlink) files from a directory like this: .name.ico , but the "name" can be anything else. I tried the .*.ico like this:

unlink("dir1/dir2/.*.ico");

but it is not successfull.

If in the code I write the correct filename like this:

unlink("dir1/dir2/.name.ico");

the procedure is succesfull, But I dont know always what is the "name" exactly, I have to masked "name" to "*"

I would like to ask for help in resolving this.

Thank you very much!

I used this as a solution:

$icofilename = (glob("dir1/dir2/.*.ico")); unlink($icofilename[1]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM