PaulW Posted January 13, 2007 Share Posted January 13, 2007 Hi thereI 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 advancePaul Link to comment https://forums.phpfreaks.com/topic/34041-use-nn-in-script-doesnt-work-on-new-server/ Share on other sites More sharing options...
ShogunWarrior Posted January 13, 2007 Share Posted January 13, 2007 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 Link to comment https://forums.phpfreaks.com/topic/34041-use-nn-in-script-doesnt-work-on-new-server/#findComment-160027 Share on other sites More sharing options...
c4onastick Posted January 13, 2007 Share Posted January 13, 2007 [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/NewlineIt may help point you in the right direction. Link to comment https://forums.phpfreaks.com/topic/34041-use-nn-in-script-doesnt-work-on-new-server/#findComment-160029 Share on other sites More sharing options...
PaulW Posted January 13, 2007 Author Share Posted January 13, 2007 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 Link to comment https://forums.phpfreaks.com/topic/34041-use-nn-in-script-doesnt-work-on-new-server/#findComment-160042 Share on other sites More sharing options...
Destruction Posted January 13, 2007 Share Posted January 13, 2007 $data_arr = preg_split("'/\n\n/',$data);Why do you have " then ' - you don't have a closing " so likely it's a simple parsing error?Dest Link to comment https://forums.phpfreaks.com/topic/34041-use-nn-in-script-doesnt-work-on-new-server/#findComment-160108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.