LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 02-20-2004, 08:40 AM   #1
patpawlowski
Member
 
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
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
I dont know if your pictures are named
Code:
p_'product number'*
or
Code:
p_*
.
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
PSIplus
Member
 
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

or

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

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

Rep: Reputation: 0
Hi!

Take a look of this

http://pi.nks.com.ar/programacion/unlink_wc.php

Bye!
 
  


Reply


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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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