writeman
03-22-2007, 07:07 AM
hi all
My filepath looks like w:/aaa/bbb/ccc/abc.doc.
I want to replace all '/' to '\'.
my code don't work and occurs error
for($i=0; $i<count($VFILE); $i++){
$tmp= $VFILE[$i];
$tmpstr='';
for($j=0; $j<strlen($tmp); $j++){
if($tmp[$j]== '/'){$tmp[$j]= "\";}
$tmpstr=$tmpstr . $tmp[$j];
}
$VFILE[$i]= $tmpstr;
}
if I change the red section code to if($tmp[$j]== '/'){$tmp[$j]= "\\";}
It works, but I got two '\\'?
Are there some codes to fit my program?
My filepath looks like w:/aaa/bbb/ccc/abc.doc.
I want to replace all '/' to '\'.
my code don't work and occurs error
for($i=0; $i<count($VFILE); $i++){
$tmp= $VFILE[$i];
$tmpstr='';
for($j=0; $j<strlen($tmp); $j++){
if($tmp[$j]== '/'){$tmp[$j]= "\";}
$tmpstr=$tmpstr . $tmp[$j];
}
$VFILE[$i]= $tmpstr;
}
if I change the red section code to if($tmp[$j]== '/'){$tmp[$j]= "\\";}
It works, but I got two '\\'?
Are there some codes to fit my program?