remove spaces

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

remove spaces

Post by kanchan »

<?

$folder_name = $_POST['name'];

mkdir("/path/$folder_name", 0777);

?>

i think the above code makes a directory as the user inputs the folder name...

Now, what i want is, if the user gives space in between the text like "my design works" then i want this text to renamed to "my_design_works"
..
so how to do that??

and if that folder exists then i want the new folder to be renamed automatically with new name...

i know i m very bad at PHP so..

waiting for your help guys....
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: remove spaces

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

Re: remove spaces

Post by kanchan »

do you mind if you please post the code... coz i m so new to PHP..... please.....
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: remove spaces

Post by VladSun »

kanchan wrote:do you mind if you please post the code... coz i m so new to PHP..... please.....
Try to figure out the code - if you don't succeed, post the code you are trying with and I'll help you.
There are 10 types of people in this world, those who understand binary and those who don't
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

Re: remove spaces

Post by kanchan »

VladSun wrote:
kanchan wrote:do you mind if you please post the code... coz i m so new to PHP..... please.....
Try to figure out the code - if you don't succeed, post the code you are trying with and I'll help you.

if i was that much good then i wudnt have posted here... ;)

anyways..i find out the code .... thanks... :lol: :lol: :lol:
kanchan
Forum Commoner
Posts: 80
Joined: Tue Nov 30, 2004 12:03 pm

Re: remove spaces

Post by kanchan »

Now what i want is if it founds the folder name already exists then i wanna rename the new folder to user inputted name with random numbers at the last...

<?php
$name = '/path/foldername;

if (file_exists($name)) {
rename the folder like this : my_design_works12312312 ;
} else {
mkdir("/path/$folder_name ", 0777);
}
?>
Post Reply