Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-20-2004, 08:40 AM   #1
Registered: Mar 2003
Location: Centreville, Virginia
Distribution: Mandrak, Red Hat
Posts: 163

Rep: Reputation: 30
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?
Old 02-20-2004, 09:53 AM   #2
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
I dont know if your pictures are named
p_'product number'*
Assuming the second:
you can concat p_ to product number using dot (.) operator. For example
PHP Code:
unlink ("p_".$pNum); 
where pNum contains the product number.

If this doesn't help, take a look at ereg() manual.
Old 02-20-2004, 09:57 AM   #3
Registered: Feb 2004
Location: Vienna/Austria
Distribution: Debian Unstable
Posts: 36

Rep: Reputation: 15
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


do it the nice way:
system("rm whatever");

with exec && system you can execute shell commands :-)
Old 03-18-2004, 09:20 AM   #4
LQ Newbie
Registered: Mar 2004
Location: Santa Fe, Argentina
Distribution: LFS
Posts: 1

Rep: Reputation: 0

Take a look of this



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: huge functions file vs multiple small files carlosruiz Programming 2 06-14-2005 03:06 AM
PHP about functions djgerbavore Programming 1 11-25-2004 07:14 PM
functions in PHP gaddargarson Programming 3 10-07-2004 02:02 PM
php: array with functions ldp Programming 7 09-22-2004 04:55 PM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 11:51 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration