on my linux based system
echo ord(\n);
is 10 which is 0A in hex. windows machings usually consider newline to be 0A0D or 0D0A
mac's usually are 0D I would convert your file. I have to do this often with file
uploads.
// convert all 0A0D and 0D0A to 0A0A
$data = str_replace(chr(13), chr(10), $data);
// convert all 0A0A to 0A
$data = str_replace(chr(10).chr(10), chr(10), $data);
this will standardize it for you.
--
Chris Lee
[EMAIL PROTECTED]
Hannes Schmiderer [EMAIL PROTECTED] wrote in message
9dtv8b$cud$[EMAIL PROTECTED]">news:9dtv8b$cud$[EMAIL PROTECTED]...
Hi!
$astrData = file($astrCounterFile[$i]);
echo |\n|br;
echo | . $astrData[0] . |br;
echo | . $astrData[1] . |br;
//$astrData[1] = \n;
//echo | . $astrData[1] . |br;
echo | . $astrData[2] . |br;
for($k = 0; strcmp($astrData[$k] , \n) ($k 50); $k++)
// for($k = 0; ($astrData[$k] \n) ($k 50); $k++)
{
echo | . $astrData[$k] . | . br;
}
I use 4.0.5 Win32 CGI, At the moment FTP at my host is down, so I cannot
test it on another system.
I have a textfile with line breaks and some empty lines in it. I read it
with file() into an array. When I output the lines, I can see in the hex
editor that the second line contains only a newline (0D 0A). When I output
\n it is 0D 0A, too.
The strange thing is, that, when I compare this array element (with the
emtpy line) with \n It is never true! Not with strcmp, strncmp or .
When I remove the comments (//) and set $astrData[1]=\n explicit it works!
Note that echo | . $astrData[1] . |br; befor and after the assignment
have the same output (in hex editor).
Is this a type problem, are newlines internaly handled differently to usual
strings?
Thanx for help
Hannes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]