$LINE = $User.",".$data[$k][10];
echo $LINE;
$str=implode("",file('Friends.php'));
$fp=fopen('Friends.php','w+');
$str=str_replace($User,$LINE,$str);
fwrite($fp,$str,strlen($str));
OK, this code is a bit weird but it just appends to a string of my choice. Out should come:
H4cKL0rD,9,1,2,3,4
but when it writes it it outputs into the file as
H4cKL0rD,9
,1,2,3,4
it adds a \n
You need to use trim to remove whitespace and newlines from your variables:
I should think this is coming in from file (which reads each line into an array), so trim each line first in a loop