Page 1 of 1

explode line breaks

Posted: Fri Aug 03, 2007 9:57 am
by m2babaey
Hi
I know we can use function explode to devide texts/strings into peices. And i know we use ln2br() to show line breaks when pulling out a text from the database.
what i need is exploding a text on line breaks.
to be more specific, users enter their keyword in a textarea and type each phrase in 1 line. I save that textarea content in 1 field but since I need to analize each phrase, I want to devide that text into keyword phrases when i use SELECT to pull it out
how can I do that?
thanks

Posted: Fri Aug 03, 2007 10:04 am
by John Cartwright

Code: Select all

$lines = explode(PHP_EOL, $content);

echo '<pre>';
print_r($lines);
Simple as that

Posted: Fri Aug 03, 2007 10:37 am
by dirkr
why not just explode("\n",$content) ?

Posted: Fri Aug 03, 2007 10:41 am
by John Cartwright
Line breaks differ between operating systems

Posted: Fri Aug 03, 2007 10:41 am
by MrPotatoes
*nix is \r\n
windows is \n

or the other way around. this covers both bases :)