View Full Version : explode() with new lines...
Hey guys, hoping you can help me.
I've got a textarea box, which i want to enter a bunch of things on a new line into. Once the form is submitted, the data gets sent to a MySQL database. I want to use PHP's explode function to break each new line into it's own entry in an array.
This is where I hit a snag.
No matter what I make the delimiter, it won't work. I've tried "\r\n", "\r", "\n" and all variations thereof. I can't get it to split in it's own array entries.
What am I doing wrong?
Thanks in advance ;)
Agnostic Bear
08-11-2008, 08:55 AM
Remember to put \\ not \ ;)
Decode
08-11-2008, 09:35 AM
You could cheat and do
explode("
", $textarea);
Jebbo.
08-11-2008, 10:38 AM
you need to put // =] dont realy no much about php tho so i carnt realy help.
Jackboy
08-11-2008, 12:14 PM
you need to put // =] dont realy no much about php tho so i carnt realy help.
All you did is read Jewish Bear's post, and because you know he's ought to be right because hes amazing at PHP, you just repeated his response.
-rep if i can
Calon
08-11-2008, 01:20 PM
All you did is read Jewish Bear's post, and because you know he's ought to be right because hes amazing at PHP, you just repeated his response.
-rep if i can
I was just about to post the same.
Don't bother posting if you're not offering help, you're just repeating it..
Fail.
you need to put // =] dont realy no much about php tho so i carnt realy help.
Not only did you copy, you failed to notice that it's \\, not //.
Dentafrice
08-11-2008, 03:01 PM
You could just easily do this..
$text = nl2br( $text );
$text = explode( '<br />', $text );
Puts them into an array...
print_r() if you want to see the values.. then just throw them into a foreach and you can do what you want with them..
foreach( $text as $line ) {
// your variable here is going to be $line, do what you want with it.
echo $line;
}
Cushioned
08-11-2008, 07:57 PM
I was just about to post the same.
Don't bother posting if you're not offering help, you're just repeating it..
Fail.
Lol. Thinking the same think -REP for Jebbo if I can also. .
EDIT: Ah shiz lol wasn't paying attention and +REP'd him LOOOOl Dumb me :O
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.