Hello,

I have a Flash application that's sending data from a simple input dynamic text field to a php script that saves it to a database.       I then retrieve the data from the database and export it to a csv file.     I am having problems w/ the wrapped text from the flash application causing the csv file to display the text in a newline.

When I try to detect the usual newline characters, (IE. \n, \r, \n\r) I am not finding any in the text.

here's the line of php code i'm using to try to detect any newline chars:

if(preg_match("#[\n|\r|\r\n][ ]*$#", $row_export['data_dump'] ) ){  echo "Newline characters found!"; }else{ echo "NO NEWLINES OR CARRIAGE RETURNS";  }	

Is there any different newline or wrap characters that I could be testing for?

Thanks,
Clem C

    Have you tested your regex pattern on a string that you know has newlines? I seem to recall that in some cases you have to double your backslashes. I don't recall why. You might also need to be in multi-line mode!

    if(preg_match("#[\n|\r|\r\n][ ]*$#s", $row_export['data_dump'] ) ){  echo "Newline characters found!"; }else{ echo "NO NEWLINES OR CARRIAGE RETURNS";  }	
    

    NOTE the 's' after the # ending your pattern.
    If you think the newline field is something you aren't already searching for, you can echo the ASCII values of the text that has been input:

    $str = "though i walk through the valley of the shadow of death
    i shall fear no evil
    cuz i am the meanest sob in the valley";
    $len = strlen($str);
    for ($i=0; $i<$len; $i++) {
      echo $str[$i] . '=ord(' . ord($str[$i]) . ')<br>';
    }
    
      Write a Reply...