Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
replacing characters in a file name?
Old 06-21-2008, 06:07 PM replacing characters in a file name?
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
PHP Code:
$filename preg_replace('/[\\\/:*?"<>|]/'''$filename); 
Okay, I know this is wrong obviously, but I want to create file names that are more simple.

So I only want numbers letters and - and everything else to be replaced with - how do I do this?
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
 
Register now for full access!
Old 06-21-2008, 06:55 PM Re: replacing characters in a file name?
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Instead of trying to list what you don't want, list what you do and remove the rest.
PHP Code:
$filename preg_replace('/[^a-z0-9\.]/'''$filename); 
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE

Last edited by JeremyMiller; 06-21-2008 at 06:56 PM.. Reason: Added \. to let the file extension remain as an extension, but will leave other .'s in as well.
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-22-2008, 05:00 PM Re: replacing characters in a file name?
dansgalaxy's Avatar
Defies a Status

Posts: 6,522
Name: Dan
Location: Swindon
Trades: 0
Quote:
Originally Posted by JeremyMiller View Post
Instead of trying to list what you don't want, list what you do and remove the rest.
PHP Code:
$filename preg_replace('/[^a-z0-9\.]/'''$filename); 
Lol... terrible when you have to point out the obvious.

Dan
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to replacing characters in a file name?
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11312 seconds with 12 queries