I haven't been able to find a solution similar to my problem.
I have a file on a server (UNIX). The file is in a readable format on the server (ie includes spaces, tabs, and newlines as ^M
).
If I var_dump()
the file it keeps the format but if I echo
it removes all whitespace and newlines. Is there a way to display this file the same as it would be viewed on the server? below is the way I was attempting to do this:
if($login){
$file = 'ftp://'.$username.':'.$password.'@'.$server.$path;
$contents = file_get_contents($file);
var_dump($contents);//is a string
$contents = str_replace("^M","<br>",$contents);
echo $contents;
}