Textarea Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tarja311
Forum Commoner
Posts: 73
Joined: Fri Oct 20, 2006 10:57 pm

Textarea Array

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply