Using the code below to parse a fixed width file.
list($dummy, $t1, $pn, $t2, $apn, $t3, $cc, $t4, $q, $t5, $desc, $t6)=array_values(unpack("A11dummy/A1t1/A20pn/A1t2/A20apn/A1t3/A2cc/A1t4/A5q/A1t5/A20desc/A48t6",$line));
This is the result I'm expecting:
"UPD A"
"05-910-00 "
"5999-99-234-3408 "
"NS"
"03656"
"CONTACT SOCKET "
But, I'm getting this:
"UPD A"
">05-910-00"
">5999-99-234-3408"
">N"
"0"
">CONTACT SOCKET"
There seems to be double CRs in the file like this:
UPD A>05-40-202ZW > >NS>00975>JACK POST > > > > . >Y>000000.00>EA>
UPD A>05-910-00 >5999-99-234-3408 >NS>03656>CONTACT SOCKET > >CONN > > . >Y>000000.00>EA>
Could that be causing the problem? auto_detect_line_endings is set to true.
How do I make sure it doesn't happen?
I've tried both these with no success:
$line = str_replace("\r\n", "\n", $line);
$line = str_replace("\n\n", "\n", $line);