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
preg_replace to remove spaces
Old 06-05-2008, 05:49 AM preg_replace to remove spaces
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
My website has got an area to upload files and make new folders and delete files or folders etc. I had a problem at the beginning where if a file or folder had spaces it would cause problems eg if the file name was "my folder" and was in my root upload directory, when you clicked on it to follow the link and get into the folder, it would just do nothing, I figured out that this was cause the link it was trying to open was /my and not /my folder, so I used preg_replace to replace any odd characters and spaces into underscores _ now this is not ideal for me, it works but I would rather be allowed the spaces, the other characters can be replaced if they must but spaces are a hard one to live without.

I hope someone can give an explanatory solution for this

Thanks
scorpioserve is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-05-2008, 06:28 AM Re: preg_replace to remove spaces
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
I'm guessing you've never worked with anything but Windows before? If you program you learn not to use spaces. Try this, go to Start > Run and type cmd to launch the command line, then type
Code:
cd C:\Program Files
It will complain because only the Windows GUI naturally works with spaces, you can use
Code:
cd 'C:\Program Files'
Just learn to save files with correct names. If you ever decide to code this will come into immense help. Also try not to use upper-case.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-05-2008, 07:19 AM Re: preg_replace to remove spaces
Super Talker

Posts: 116
Name: Paul
Location: South Africa
Trades: 0
Quote:
Originally Posted by Arenlor View Post
I'm guessing you've never worked with anything but Windows before? If you program you learn not to use spaces. Try this, go to Start > Run and type cmd to launch the command line, then type
Code:
cd C:\Program Files
It will complain because only the Windows GUI naturally works with spaces, you can use
Code:
cd 'C:\Program Files'
Just learn to save files with correct names. If you ever decide to code this will come into immense help. Also try not to use upper-case.
I mainly use mac, however in this particular case yes, I am using a windoze machine for this site, and you are correct in what you are saying I agree 100%, however I cannot stop the space problem, as it is not me but all the clients that are using them, now as I said I can just replace the spaces with a more acceptable character like the underscore _, however the problem is that this is a printing company and the clients are designers using apps like quark, indesign, illustrator, photoshop or freehand, and most of the designs incorporate scans, when these scans are placed into InDesign for example they become links to external tiff or psd files and these external links have spaces in them more often than not, so if they upload a brochure to their respective client folder it loses all the spaces so when we reopen it on our side to enter into our workflow we have to relink all the images one by one, I was hoping that I could use something like urlencode, but I am fighting with it.

Thanks
scorpioserve is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to preg_replace to remove spaces
 

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.55046 seconds with 12 queries