file fwrite() using "\r" and "\n" in str
Posted: Fri Jun 18, 2004 11:31 am
Hello,
The following code is being used to write $_POST array variable to a text file.
However I get the following ouput
The following code is being used to write $_POST array variable to a text file.
Code: Select all
// read files function
function FILE_ACTIONS($file,$action,$string=false){
if($action == 'r'){
$content = file($file);
}elseif($action == 'w' || $action == 'a'){
$fp = fopen($file,$action);
if(fwrite($fp,$string)){
fclose($fp);
return true;
}else{
fclose($fp);
return false;
}
}
if($content)
return $content;
else false;
}
$brands = $_POSTї'brand_name'];
if(count($brands)>0){ // if array
$brands = join("\r",$brands);
}else{ $brands = "ANY";}
FILE_ACTIONS($file,$action = "w",$string = $brands);What gives with the extra "new line"NIKE
ADIDAS
REEBOK
FILAS
K-SWISS