tags:

views:

95

answers:

2

I'm playing with SAX and noticed it's not line breaking properly. I have no iea why.

function flush_data() {

    global $level, $char_data;

    $char_data = trim($char_data);

    if( strlen( $char_data ) > 0 ) {

        print "\n";


        $data = split("\n", wordwrap($char_data, 76 - ($level*2)));
        foreach($data as $line) {
            print str_repeat(' ', ($level +1)) . "[".$line."]"."\n";
        }
    }

    $char_data = '';
}
+2  A: 

Maybe you can try

print PHP_EOL;

It almost goes without saying, if you're doing this in a web page you need

header('Content-Type: text/plain');

\r\n is incorrect, PHP_EOL is the correct way to get a platform-independent newline.

Joshua
It was the content type part. Thanks!
Doug
A: 

try

\r\n

return and new line feed work different on a windows and linux machine.

Glycerine