Using wildcards with PHP file functions
I am assuming that you cannot use wildcards # or * with the PHP unlink function. I need a way to delete the pictures off of our web page when we delete a product. All the products pictures are located in the same directory and begin with p_'product number'.... I tried the command unlink(p_'product number'*) but the files weren't deleted. I checked the php manual and they don't mention wildcards. I thougt I could write a function to scan the directory and produce a list of files to unlink but this still would reqire the use of a wildcard.
Any ideas? |
I dont know if your pictures are named
Code:
p_'product number'* Code:
p_* Assuming the second: you can concat p_ to product number using dot (.) operator. For example PHP Code:
If this doesn't help, take a look at ereg() manual. |
Wildcards are interpreted by the shell, so there are two easy solutions:
Don't use them. PHP-Functions don't interprete them. use opendir & co to scan thru a directory and use unlink or do it the nice way: system("rm whatever"); with exec && system you can execute shell commands :-) |
|
All times are GMT -5. The time now is 08:49 AM. |