Page 1 of 1

Textarea Array

Posted: Mon Sep 17, 2007 4:44 pm
by tarja311
Hi all,

I have a textarea field set up for users to enter multiple lines of text. What i am trying to do is to put each line into an array, but for some unknown reason my solution is not working.

Code: Select all

$text = explode("\r\n", $text);

  echo $arrcount = count($text);
No matter how many times i hit enter, it gives me a 1 count.

A print_r() shows :

Code: Select all

Array ( [0] => here is some text\\r\\nand here is some more text\\r\\nand some more text )
Any help would be greatly appreciated. Thanks

-- tarja

Posted: Mon Sep 17, 2007 4:55 pm
by s.dot

Code: Select all

Array ( [0] => here is some text\\r\\nand here is some more text\\r\\nand some more text )
To get the \r\n to be recognized, you have to put the string in double quotes "string".
And also, you have \\r\\n and you're trying to explode on \r\n.