Jump to content

array of file paths putting white space in front of filenames


Go to solution Solved by .josh,

Recommended Posts

Hello, i have the following code: php 5, ms server 2008, iis 7

I pass this script a csv list of file paths like so...

,C:\path\path\path\file.name,C:\path\path\anotherFile.name,C:\path\path\path\file3.file

(yes there is a leading comma in the string for some reason..)

$files = $_POST['files'];

$files = explode(',', $files)
foreach($files as $filename){
if(file_exists($filename)){

echo '":' . $filename .':"Does Exist<br />';

} else {

echo 'Sorry ":' . $filename . ':" Does Not Exist<br />';

}
}

My problem:

the first file path shows it exists and there is no white space in the string, all the file paths after the first one show like such:

 

":C:\path\path\path\file.name:" Does Exist  // 1st path (good)

": C:\path\path\anotherFile.name :" Does Not Exist

": C:\path\path\file3.file:" Does Not Exist

 

pleas note... i put the ": and :" in there to show that there is indeed a white space character in front of and behind the filepaths. EXCEPT for the last path.. there is no trailing white space there.

 

Please explain why you think the white space is being added to these and what i can do to get rid of it.

 

thanks,

dogdaynoon

 

 
 
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.