Page 1 of 1

remove spaces

Posted: Thu Oct 02, 2008 11:24 am
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....

Re: remove spaces

Posted: Thu Oct 02, 2008 11:26 am
by VladSun

Re: remove spaces

Posted: Thu Oct 02, 2008 11:30 am
by kanchan
do you mind if you please post the code... coz i m so new to PHP..... please.....

Re: remove spaces

Posted: Thu Oct 02, 2008 11:34 am
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.

Re: remove spaces

Posted: Thu Oct 02, 2008 11:39 am
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:

Re: remove spaces

Posted: Thu Oct 02, 2008 11:53 am
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);
}
?>