Jump to content

use \n\n in script-doesn't work on new server


PaulW

Recommended Posts

Hi there
I have a script which uses \n\n in preg_split, substr, etc and it worked perfectly for years on my server. Now I'm using a hosting services server and now al of a sudden it doesn't work. I tried with succes to change \n\n to chr(13).chr(10.chr(13).chr(10) with a substr part of the script.
But trying the same with preg_split just doens't work. And maybe further on in the script.

Part of script:
//This line I changed from \n\n

                $data = substr($data,strpos($data,chr(13).chr(10).chr(13).chr(10))+2);

//cannot get this to work
                $data_arr = preg_split("'/\n\n/',$data);

                $cnt = 0;
                for($i=0;$i<count($data_arr);$i++){
                  $tmp_data = array();
                        $text_data = substr($data_arr[$i],0,strpos($data_arr[$i],"<"));
                        $text_data_arr = split("\n",$text_data);
                        for($j=2;$j<count($text_data_arr);$j++)
                                $tmp_data[] = $text_data_arr[$j];
                        $tmp_url = ereg_replace("(^.*<)|(>$)",'',substr($data_arr[$i],0,strpos($data_arr[$i],">")));
                        if(count($text_data_arr)>4&&$tmp_url!='')


Are there other ways to solve this problem?
Or maybe something in php.ini to change?

thanks in advance
Paul
[quote author=ShogunWarrior link=topic=122258.msg504072#msg504072 date=1168714700]
If you are getting the content from a file and using preg on it then that could be the problem. Different systems use different combinations of \r and \n
[/quote]Shogun's right. As far as I know, *nix systems use "\n" and Windows systems use "\r\n". There's a good wiki on it here.
http://en.wikipedia.org/wiki/Newline
It may help point you in the right direction.
Thanks for the answer, but that is unfort. not the right one!

The first server was a Linux based (e-Smith/Mitel) and the files read were e-mails coming in.
The second server is as far as I know Linux Red Hat.

I tried \n\n, \r\n, just \n, with and without /*/
and chr(13).chr(10) in various combinations like 13-10,13-13,10-10,10-13,10,13, etc.

Regards

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.