Problem using PHP to open text file - blank spaces are removed
- by Reg H
Hi All,
I'm trying to open and process ASCII files using PHP, but am having problems. The problem
is that the blank spaces are removed, which I don't want to have happen, since the files are fixed width.
The PHP script I used is this:
$myFile = Test.SEG";
$file_handler = fopen ($myFile, r) or die ("Can't open SEG File.");
while (!feof($file_handler))
{
$dataline = fgets($file_handler);
echo $dataline, "";
}
I tried pasting samples of the original file in here, but the spaces were removed here as well!
At this stage I'm just building the script in steps, getting one step working at a time, but this is as far as I've gotten. I plan to use substr() on '$dataline' to pick out the fields I need.
Any suggestions on how to keep the spaces intact? Something tells me it's something to do with encoding, but I don't know for sure.
Thanks!